Skip to content

Commit

Permalink
config: use json for unmarshal test
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Nov 3, 2021
1 parent 11509ee commit 1f4ed84
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package config_test

import (
"encoding/json"
"testing"

"github.com/google/go-cmp/cmp"
"gopkg.in/yaml.v3"

"github.com/quay/clair/v4/config"
)
Expand Down Expand Up @@ -235,12 +235,7 @@ func TestAuthUnmarshal(t *testing.T) {
}
tt := []testcase{
{
In: `---
key: >-
ZGVhZGJlZWZkZWFkYmVlZg==
iss:
- iss
`,
In: `{"key":"ZGVhZGJlZWZkZWFkYmVlZg==","iss":["iss"]}`,
Want: config.AuthPSK{
Key: []byte("deadbeefdeadbeef"),
Issuer: []string{"iss"},
Expand All @@ -250,7 +245,7 @@ iss:

check := func(t *testing.T, tc testcase) {
v := config.AuthPSK{}
if err := yaml.Unmarshal([]byte(tc.In), &v); err != nil {
if err := json.Unmarshal([]byte(tc.In), &v); err != nil {
t.Error(err)
}
if got, want := v, tc.Want; !cmp.Equal(got, want) {
Expand All @@ -269,11 +264,7 @@ iss:
}
tt := []testcase{
{
In: `---
api: quay/keys
intraservice: >-
ZGVhZGJlZWZkZWFkYmVlZg==
`,
In: `{"api":"quay/keys","intraservice":"ZGVhZGJlZWZkZWFkYmVlZg=="}`,
Want: config.AuthKeyserver{
API: "quay/keys",
Intraservice: []byte("deadbeefdeadbeef"),
Expand All @@ -283,7 +274,7 @@ intraservice: >-

check := func(t *testing.T, tc testcase) {
v := config.AuthKeyserver{}
if err := yaml.Unmarshal([]byte(tc.In), &v); err != nil {
if err := json.Unmarshal([]byte(tc.In), &v); err != nil {
t.Error(err)
}
if got, want := v, tc.Want; !cmp.Equal(got, want) {
Expand Down

0 comments on commit 1f4ed84

Please sign in to comment.