Skip to content

Commit d7f8e8e

Browse files
committed
add unit test, correct errors package
Signed-off-by: garfthoffman <[email protected]>
1 parent b103e4a commit d7f8e8e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

go/vt/tableacl/tableacl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
111111
return err
112112
}
113113
if len(data) == 0 {
114-
return error.New("tableACL config file is empty")
114+
return errors.New("tableACL config file is empty")
115115
}
116116

117117
config := &tableaclpb.Config{}

go/vt/tableacl/tableacl_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ func TestInitWithValidConfig(t *testing.T) {
7474
}
7575
}
7676

77+
func TestInitWithEmptyConfig(t *testing.T) {
78+
tacl := tableACL{factory: &simpleacl.Factory{}}
79+
f, err := os.CreateTemp("", "tableacl")
80+
if err != nil {
81+
t.Fatal(err)
82+
}
83+
defer os.Remove(f.Name())
84+
if err := f.Close(); err != nil {
85+
t.Fatal(err)
86+
}
87+
if err := tacl.init(f.Name(), func() {}); err == nil {
88+
t.Fatal("tableACL config file is empty")
89+
}
90+
}
91+
7792
func TestInitFromProto(t *testing.T) {
7893
tacl := tableACL{factory: &simpleacl.Factory{}}
7994
readerACL := tacl.Authorized("my_test_table", READER)

0 commit comments

Comments
 (0)