-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test and trailing new line to
apko.lock.json
files.
- There was no test that `apko lock' command works - Some code-quality tools like end-of-file-fixer were annoyed thay .apko.lock.files are not ending with a new-line character. Signed-off-by: Piotr Tabor <piotr.tabor@snowflake.com>
- Loading branch information
1 parent
c10dc55
commit 37eae4b
Showing
4 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2023 Chainguard, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cli_test | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"github.com/stretchr/testify/require" | ||
|
||
"chainguard.dev/apko/internal/cli" | ||
"chainguard.dev/apko/pkg/build" | ||
"chainguard.dev/apko/pkg/build/types" | ||
) | ||
|
||
func TestLock(t *testing.T) { | ||
ctx := context.Background() | ||
tmp := t.TempDir() | ||
|
||
golden := filepath.Join("testdata", "apko.lock.json") | ||
|
||
config := filepath.Join("testdata", "apko.yaml") | ||
archs := types.ParseArchitectures([]string{"amd64", "arm64"}) | ||
opts := []build.Option{build.WithConfig(config)} | ||
outputPath := filepath.Join(tmp, "apko.lock.json") | ||
|
||
err := cli.LockCmd(ctx, outputPath, archs, opts) | ||
require.NoError(t, err) | ||
|
||
want, err := os.ReadFile(golden) | ||
require.NoError(t, err) | ||
got, err := os.ReadFile(outputPath) | ||
require.NoError(t, err) | ||
|
||
if !bytes.Equal(want, got) { | ||
if diff := cmp.Diff(want, got); diff != "" { | ||
t.Errorf("Mismatched lock files: (-%q +%q):\n%s", golden, outputPath, diff) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,4 @@ | |
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters