Add a test to determine if a blob is binary or not

This commit is contained in:
Yuichi Watanabe 2020-07-30 13:10:07 +09:00
parent 3d29c861a6
commit b158de5685
1 changed files with 19 additions and 1 deletions

View File

@ -28,7 +28,21 @@ func TestCreateBlobFromBuffer(t *testing.T) {
t.Fatal("Empty buffer did not deliver empty blob id")
}
for _, data := range []([]byte){[]byte("hello there"), doublePointerBytes()} {
tests := []struct {
data []byte
isBinary bool
}{
{
data: []byte("hello there"),
isBinary: false,
},
{
data: doublePointerBytes(),
isBinary: true,
},
}
for _, tt := range tests {
data := tt.data
id, err = repo.CreateBlobFromBuffer(data)
checkFatal(t, err)
@ -38,5 +52,9 @@ func TestCreateBlobFromBuffer(t *testing.T) {
t.Fatal("Loaded bytes don't match original bytes:",
blob.Contents(), "!=", data)
}
want := tt.isBinary
if got := blob.IsBinary(); got != want {
t.Fatalf("IsBinary() = %v, want %v", got, want)
}
}
}