Skip to content

Commit

Permalink
test(logging): adtl Format testing
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyMerrick committed Sep 26, 2023
1 parent 9d9772d commit a000fd0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions router/middleware/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func TestMiddleware_Format(t *testing.T) {
"status": http.StatusOK,
"user-agent": "foobar",
"version": "v1.0.0",
"org": "foo",
}

logger := logrus.NewEntry(logrus.StandardLogger())
Expand All @@ -249,10 +250,12 @@ func TestMiddleware_Format(t *testing.T) {

wantLabels := "labels.vela"
wantMethod := http.MethodGet
wantOrg := "foo"

// run test
gotLabels := string(formatter.DataKey)
gotMethod := entry.Data["method"]
gotOrg := entry.Data["org"]

if err != nil {
fmt.Println("err:", err.Error())
Expand All @@ -270,4 +273,12 @@ func TestMiddleware_Format(t *testing.T) {
t.Errorf("Logger returned %v, want %v", gotMethod, wantMethod)
}

if !reflect.DeepEqual(wantMethod, gotMethod) {
t.Errorf("Logger returned %v, want %v", gotMethod, wantMethod)
}

if !reflect.DeepEqual(wantOrg, gotOrg) {
t.Errorf("Logger returned %v, want %v", gotOrg, wantOrg)
}

}

0 comments on commit a000fd0

Please sign in to comment.