generated from ViBiOh/goweb
-
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.
fix: Using correct ID for user in ketchup store (#35)
- Loading branch information
Showing
11 changed files
with
215 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package model | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func TestReadUser(t *testing.T) { | ||
type args struct { | ||
ctx context.Context | ||
} | ||
|
||
var cases = []struct { | ||
intention string | ||
args args | ||
want User | ||
}{ | ||
{ | ||
"empty", | ||
args{ | ||
ctx: context.Background(), | ||
}, | ||
NoneUser, | ||
}, | ||
{ | ||
"with User", | ||
args{ | ||
ctx: StoreUser(context.Background(), User{ID: 8000, Email: "nobody@localhost"}), | ||
}, | ||
User{ID: 8000, Email: "nobody@localhost"}, | ||
}, | ||
{ | ||
"not an User", | ||
args{ | ||
ctx: context.WithValue(context.Background(), ctxUserKey, args{}), | ||
}, | ||
NoneUser, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.intention, func(t *testing.T) { | ||
if got := ReadUser(tc.args.ctx); got != tc.want { | ||
t.Errorf("ReadUser() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.