-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude example directory from tests
- Loading branch information
Showing
8 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package logger | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestLogger(t *testing.T) { | ||
buff := bytes.NewBufferString("") | ||
lg := Func(func(format string, args ...interface{}) { | ||
fmt.Fprintf(buff, format, args...) | ||
}) | ||
|
||
lg.Logf("blah %s %d something", "str", 123) | ||
|
||
if !strings.HasSuffix(buff.String(), "blah str 123 something") { | ||
t.Errorf("wrong log output: %s", buff.String()) | ||
} | ||
} | ||
|
||
func TestStd(t *testing.T) { | ||
buff := bytes.NewBufferString("") | ||
log.SetOutput(buff) | ||
defer log.SetOutput(os.Stdout) | ||
|
||
Std.Logf("blah %s %d something", "str", 123) | ||
|
||
if !strings.HasSuffix(buff.String(), "blah str 123 something\n") { | ||
t.Errorf("wrong log output: %s", buff.String()) | ||
} | ||
} | ||
|
||
func TestNoOp(t *testing.T) { | ||
buff := bytes.NewBufferString("") | ||
log.SetOutput(buff) | ||
defer log.SetOutput(os.Stdout) | ||
|
||
NoOp.Logf("blah %s %d something", "str", 123) | ||
|
||
if buff.String() != "" { | ||
t.Errorf("wrong log output: %s", buff.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package user | ||
|
||
import "testing" | ||
|
||
func TestUser_SetAttr(t *testing.T) { | ||
type fields struct { | ||
UserID string | ||
Username string | ||
Attributes map[string]interface{} | ||
Disabled bool | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
}{ | ||
{ | ||
name: "TestUser_SetAttr", | ||
fields: fields{ | ||
UserID: "test", | ||
Username: "test", | ||
Attributes: make(map[string]interface{}), | ||
Disabled: false, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
u := &User{ | ||
UserID: tt.fields.UserID, | ||
Username: tt.fields.Username, | ||
Attributes: tt.fields.Attributes, | ||
Disabled: tt.fields.Disabled, | ||
} | ||
u.SetAttr("test", "test") | ||
|
||
if u.Attributes["test"] != "test" { | ||
t.Errorf("SetAttr() error = %v", u.Attributes["test"]) | ||
return | ||
} | ||
}) | ||
} | ||
} |