Skip to content

Commit

Permalink
add unit test, correct errors package
Browse files Browse the repository at this point in the history
Signed-off-by: garfthoffman <[email protected]>
  • Loading branch information
garfthoffman committed Nov 22, 2024
1 parent d79d1c8 commit d47a37b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/tableacl/tableacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
return err
}
if len(data) == 0 {
return error.New("tableACL config file is empty")
return errors.New("tableACL config file is empty")
}

config := &tableaclpb.Config{}
Expand Down
15 changes: 15 additions & 0 deletions go/vt/tableacl/tableacl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ func TestInitWithValidConfig(t *testing.T) {
}
}

func TestInitWithEmptyConfig(t *testing.T) {
tacl := tableACL{factory: &simpleacl.Factory{}}
f, err := os.CreateTemp("", "tableacl")
if err != nil {
t.Fatal(err)
}
defer os.Remove(f.Name())
if err := f.Close(); err != nil {
t.Fatal(err)
}
if err := tacl.init(f.Name(), func() {}); err == nil {
t.Fatal("tableACL config file is empty")
}
}

func TestInitFromProto(t *testing.T) {
tacl := tableACL{factory: &simpleacl.Factory{}}
readerACL := tacl.Authorized("my_test_table", READER)
Expand Down

0 comments on commit d47a37b

Please sign in to comment.