Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: remove unnecessary declaration and fix typo #4951

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/buildctl/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ func buildAction(clicontext *cli.Context) error {
}

func writeMetadataFile(filename string, exporterResponse map[string]string) error {
var err error
out := make(map[string]interface{})
for k, v := range exporterResponse {
dt, err := base64.StdEncoding.DecodeString(v)
Expand Down
14 changes: 7 additions & 7 deletions cmd/buildctl/buildctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestWriteMetadataFile(t *testing.T) {
cases := []struct {
name string
exporterResponse map[string]string
excpected map[string]interface{}
expected map[string]interface{}
}{
{
name: "common",
Expand All @@ -52,7 +52,7 @@ func TestWriteMetadataFile(t *testing.T) {
"containerimage.descriptor": "eyJtZWRpYVR5cGUiOiJhcHBsaWNhdGlvbi92bmQub2NpLmltYWdlLm1hbmlmZXN0LnYxK2pzb24iLCJkaWdlc3QiOiJzaGEyNTY6MTlmZmVhYjZmOGJjOTI5M2FjMmMzZmRmOTRlYmUyODM5NjI1NGM5OTNhZWEwYjVhNTQyY2ZiMDJlMDg4M2ZhMyIsInNpemUiOjUwNiwiYW5ub3RhdGlvbnMiOnsib3JnLm9wZW5jb250YWluZXJzLmltYWdlLmNyZWF0ZWQiOiIyMDIyLTAyLTA4VDE5OjIxOjAzWiJ9fQ==", // {"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3","size":506,"annotations":{"org.opencontainers.image.created":"2022-02-08T19:21:03Z"}}
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
excpected: map[string]interface{}{
expected: map[string]interface{}{
"containerimage.config.digest": "sha256:2937f66a9722f7f4a2df583de2f8cb97fc9196059a410e7f00072fc918930e66",
"containerimage.descriptor": map[string]interface{}{
"annotations": map[string]interface{}{
Expand All @@ -71,7 +71,7 @@ func TestWriteMetadataFile(t *testing.T) {
"key": "MTI=", // 12
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
excpected: map[string]interface{}{
expected: map[string]interface{}{
"key": "MTI=",
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
Expand All @@ -82,7 +82,7 @@ func TestWriteMetadataFile(t *testing.T) {
"key": "e30=", // {}
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
excpected: map[string]interface{}{
expected: map[string]interface{}{
"key": "e30=",
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
Expand All @@ -93,7 +93,7 @@ func TestWriteMetadataFile(t *testing.T) {
"key": "W10=", // []
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
excpected: map[string]interface{}{
expected: map[string]interface{}{
"key": "W10=",
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
Expand All @@ -104,7 +104,7 @@ func TestWriteMetadataFile(t *testing.T) {
"key": "eyJmb28iOm51bGwsImJhciI6ImJheiJ9", // {"foo":null,"bar":"baz"}
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
},
excpected: map[string]interface{}{
expected: map[string]interface{}{
"key": map[string]interface{}{
"foo": nil,
"bar": "baz",
Expand All @@ -123,7 +123,7 @@ func TestWriteMetadataFile(t *testing.T) {
require.NoError(t, err)
var raw map[string]interface{}
require.NoError(t, json.Unmarshal(current, &raw))
require.Equal(t, tt.excpected, raw)
require.Equal(t, tt.expected, raw)
})
}
}
Loading