52 lines
900 B
Go
52 lines
900 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestUpdateUserKey(t *testing.T) {
|
|
user := User{
|
|
Username: "bob",
|
|
Key: "12345",
|
|
IpAddress: "12.12.12.12:50123",
|
|
IsAdmin: false,
|
|
}
|
|
|
|
want := "67890"
|
|
|
|
user.UpdateUserKey(want)
|
|
if user.Key != want {
|
|
t.Errorf("Expected key %v, got %v", want, user.Key)
|
|
}
|
|
}
|
|
|
|
func TestUpdateUserIp(t *testing.T) {
|
|
user := User{
|
|
Username: "bob",
|
|
Key: "12345",
|
|
IpAddress: "12.12.12.12:50123",
|
|
IsAdmin: false,
|
|
}
|
|
|
|
want := "13.13.13.13:50124"
|
|
|
|
user.UpdateUserIp(want)
|
|
if user.IpAddress != want {
|
|
t.Errorf("Expected key %v, got %v", want, user.IpAddress)
|
|
}
|
|
}
|
|
|
|
func TestAddAdmin(t *testing.T) {
|
|
user := User{
|
|
Username: "bob",
|
|
Key: "12345",
|
|
IpAddress: "12.12.12.12:50123",
|
|
IsAdmin: false,
|
|
}
|
|
|
|
want := true
|
|
|
|
user.UpdateAdminStatus(want)
|
|
if user.IsAdmin != want {
|
|
t.Errorf("Expected key %v, got %v", want, user.IsAdmin)
|
|
}
|
|
}
|