Skip to content

Commit c1113b1

Browse files
authored
Merge pull request moby#4951 from hezhizhen/writemetadatafile-test
tests: remove unnecessary declaration and fix typo
2 parents 41c868b + 2f9860e commit c1113b1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

cmd/buildctl/build.go

-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ func buildAction(clicontext *cli.Context) error {
424424
}
425425

426426
func writeMetadataFile(filename string, exporterResponse map[string]string) error {
427-
var err error
428427
out := make(map[string]interface{})
429428
for k, v := range exporterResponse {
430429
dt, err := base64.StdEncoding.DecodeString(v)

cmd/buildctl/buildctl_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestWriteMetadataFile(t *testing.T) {
4343
cases := []struct {
4444
name string
4545
exporterResponse map[string]string
46-
excpected map[string]interface{}
46+
expected map[string]interface{}
4747
}{
4848
{
4949
name: "common",
@@ -52,7 +52,7 @@ func TestWriteMetadataFile(t *testing.T) {
5252
"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"}}
5353
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
5454
},
55-
excpected: map[string]interface{}{
55+
expected: map[string]interface{}{
5656
"containerimage.config.digest": "sha256:2937f66a9722f7f4a2df583de2f8cb97fc9196059a410e7f00072fc918930e66",
5757
"containerimage.descriptor": map[string]interface{}{
5858
"annotations": map[string]interface{}{
@@ -71,7 +71,7 @@ func TestWriteMetadataFile(t *testing.T) {
7171
"key": "MTI=", // 12
7272
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
7373
},
74-
excpected: map[string]interface{}{
74+
expected: map[string]interface{}{
7575
"key": "MTI=",
7676
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
7777
},
@@ -82,7 +82,7 @@ func TestWriteMetadataFile(t *testing.T) {
8282
"key": "e30=", // {}
8383
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
8484
},
85-
excpected: map[string]interface{}{
85+
expected: map[string]interface{}{
8686
"key": "e30=",
8787
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
8888
},
@@ -93,7 +93,7 @@ func TestWriteMetadataFile(t *testing.T) {
9393
"key": "W10=", // []
9494
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
9595
},
96-
excpected: map[string]interface{}{
96+
expected: map[string]interface{}{
9797
"key": "W10=",
9898
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
9999
},
@@ -104,7 +104,7 @@ func TestWriteMetadataFile(t *testing.T) {
104104
"key": "eyJmb28iOm51bGwsImJhciI6ImJheiJ9", // {"foo":null,"bar":"baz"}
105105
"containerimage.digest": "sha256:19ffeab6f8bc9293ac2c3fdf94ebe28396254c993aea0b5a542cfb02e0883fa3",
106106
},
107-
excpected: map[string]interface{}{
107+
expected: map[string]interface{}{
108108
"key": map[string]interface{}{
109109
"foo": nil,
110110
"bar": "baz",
@@ -123,7 +123,7 @@ func TestWriteMetadataFile(t *testing.T) {
123123
require.NoError(t, err)
124124
var raw map[string]interface{}
125125
require.NoError(t, json.Unmarshal(current, &raw))
126-
require.Equal(t, tt.excpected, raw)
126+
require.Equal(t, tt.expected, raw)
127127
})
128128
}
129129
}

0 commit comments

Comments
 (0)