fix(05): WR-04 default File.IsPublic to true without trapping false
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package attach
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gocloud.dev/blob/memblob"
|
||||
@@ -12,6 +14,29 @@ func TestFileTableName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileIsPublicDefaultsTrue(t *testing.T) {
|
||||
unset := File{}
|
||||
if !unset.Public() {
|
||||
t.Fatal("unset IsPublic must be public")
|
||||
}
|
||||
f, ok := reflect.TypeOf(File{}).FieldByName("IsPublic")
|
||||
if !ok {
|
||||
t.Fatal("missing IsPublic")
|
||||
}
|
||||
tag := f.Tag.Get("gorm")
|
||||
if !strings.Contains(tag, "default:true") {
|
||||
t.Fatalf("gorm tag = %q, want default:true", tag)
|
||||
}
|
||||
priv := false
|
||||
if (File{IsPublic: &priv}).Public() {
|
||||
t.Fatal("explicit false must not be public")
|
||||
}
|
||||
pub := true
|
||||
if !(File{IsPublic: &pub}).Public() {
|
||||
t.Fatal("explicit true must be public")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileSelfRegisters(t *testing.T) {
|
||||
for _, m := range All() {
|
||||
switch m.(type) {
|
||||
|
||||
Reference in New Issue
Block a user