Supercharged test coverage back up to 99.9%

I can't test that one line in the index, so this will do.

Now to complete the document for what's changed.
This commit is contained in:
Dave Shanley
2022-11-15 15:39:02 -05:00
parent 12594fdf1c
commit 59bf83c446
17 changed files with 363 additions and 103 deletions

View File

@@ -4,6 +4,7 @@
package low
import (
"crypto/sha256"
"fmt"
"github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/resolver"
@@ -1488,3 +1489,26 @@ x-tacos: [1,2,3]`
}
}
}
type test_fresh struct {
val string
}
func (f test_fresh) Hash() [32]byte {
return sha256.Sum256([]byte(f.val))
}
func TestAreEqual(t *testing.T) {
assert.True(t, AreEqual(test_fresh{val: "hello"}, test_fresh{val: "hello"}))
assert.False(t, AreEqual(test_fresh{val: "hello"}, test_fresh{val: "goodbye"}))
assert.False(t, AreEqual(nil, nil))
}
func TestGenerateHashString(t *testing.T) {
assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
GenerateHashString(test_fresh{val: "hello"}))
assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
GenerateHashString("hello"))
}