Files
geniusrun/backend/internal/garmin/client_test.go

23 lines
652 B
Go
Raw Normal View History

package garmin
import "testing"
func TestParseAuthResult(t *testing.T) {
cases := []struct {
msg string
want AuthStatus
}{
{"Authenticated successfully.", AuthSuccess},
{"MFA accepted. Authenticated successfully.", AuthSuccess},
{"MFA required. Garmin has sent a verification code...", AuthMFARequired},
{"Authentication failed: 401 Unauthorized (Invalid Username or Password)", AuthFailed},
{"Authentication failed after MFA: bad code", AuthFailed},
}
for _, c := range cases {
got := parseAuthResult(c.msg)
if got.Status != c.want {
t.Errorf("parseAuthResult(%q).Status = %v, want %v", c.msg, got.Status, c.want)
}
}
}