package security import "testing" func TestHashAndCheckPassword(t *testing.T) { pw := "correct horse battery staple" hash, err := HashPassword(pw) if err != nil { t.Fatalf("HashPassword returned error: %v", err) } if hash == "" { t.Fatalf("expected non-empty hash") } if !CheckPassword(pw, hash) { t.Fatalf("expected CheckPassword to succeed for correct password") } if CheckPassword("wrong", hash) { t.Fatalf("expected CheckPassword to fail for wrong password") } }