2020-06-10 09:07:23 -04:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDockerContextMetadataKeepAdditionalFields(t *testing.T) {
|
|
|
|
c := DockerContext{
|
2022-02-22 07:46:35 -05:00
|
|
|
Description: "test",
|
2020-06-10 09:07:23 -04:00
|
|
|
AdditionalFields: map[string]interface{}{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
jsonBytes, err := json.Marshal(c)
|
|
|
|
assert.NilError(t, err)
|
2022-02-22 07:46:35 -05:00
|
|
|
assert.Equal(t, `{"Description":"test","foo":"bar"}`, string(jsonBytes))
|
2020-06-10 09:07:23 -04:00
|
|
|
|
|
|
|
var c2 DockerContext
|
|
|
|
assert.NilError(t, json.Unmarshal(jsonBytes, &c2))
|
|
|
|
assert.Equal(t, c2.AdditionalFields["foo"], "bar")
|
|
|
|
assert.Equal(t, c2.Description, "test")
|
|
|
|
}
|