Skip to content

Commit

Permalink
zapx: add test for log builder
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Apr 24, 2019
1 parent a8f7747 commit dc13568
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
vendor
tmp
38 changes: 38 additions & 0 deletions zapx_test.go
@@ -0,0 +1,38 @@
package zapx

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNew(t *testing.T) {
type args struct {
logpath string
dev bool
}
tests := []struct {
name string
args args
wantErr bool
}{
{"dev-no-path", args{"", true}, false},
{"prod-no-path", args{"", false}, false},
{"dev-with-path", args{"./tmp/log", true}, false},
{"prod-with-path", args{"./tmp/log", false}, false},
{"bad-dir-dev", args{"/root/toor", true}, true},
{"bad-dir-prod", args{"/root/toor", false}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := New(tt.args.logpath, tt.args.dev)
if tt.wantErr {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.NotNil(t, got)
}
})
}
}

0 comments on commit dc13568

Please sign in to comment.