Skip to content

Commit

Permalink
add unittest for verify
Browse files Browse the repository at this point in the history
  • Loading branch information
derpsteb committed Nov 27, 2024
1 parent 0209e52 commit a85f2f2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions sdk/verify_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package sdk

import (
"testing"
)

func TestVerify(t *testing.T) {
tests := map[string]struct {
expectedManifest []byte
manifestHistory [][]byte
errMsg string
}{
"Empty manifest history": {
expectedManifest: []byte("expected"),
manifestHistory: [][]byte{},
errMsg: "manifest history is empty",
},
"Matching manifest": {
expectedManifest: []byte("expected"),
manifestHistory: [][]byte{[]byte("old"), []byte("expected")},
},
"Non-matching manifest": {
expectedManifest: []byte("expected"),
manifestHistory: [][]byte{[]byte("old"), []byte("current")},
errMsg: "active manifest does not match expected manifest",
},
}

for name, tt := range tests {
t.Run(name, func(t *testing.T) {
client := Client{}
err := client.Verify(tt.expectedManifest, tt.manifestHistory)

if err != nil && err.Error() != tt.errMsg {
t.Errorf("actual error: '%v', expected error: '%v'", err, tt.errMsg)
}
})
}
}

0 comments on commit a85f2f2

Please sign in to comment.