- Update provider-adapter-foundation roadmap milestone - Refactor storage layer (postgres, storage interfaces) - Add provider package with tests - Update runtime tests for control plane - Add migration for provider store - Archive completed task artifacts
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package provider
|
|
|
|
import "testing"
|
|
|
|
func TestConfigNormalizedTrimsIdentityFields(t *testing.T) {
|
|
config := Config{
|
|
ID: ProviderID(" GitHub "),
|
|
Endpoint: " https://api.github.com ",
|
|
CredentialRef: " secret://gito/providers/github ",
|
|
Capabilities: CapabilityChangeRequest | CapabilityWebhook,
|
|
}
|
|
|
|
got := config.Normalized()
|
|
|
|
if got.ID != ProviderGitHub {
|
|
t.Fatalf("ID: got %q want %q", got.ID, ProviderGitHub)
|
|
}
|
|
if got.Endpoint != "https://api.github.com" {
|
|
t.Fatalf("Endpoint: got %q", got.Endpoint)
|
|
}
|
|
if got.CredentialRef != "secret://gito/providers/github" {
|
|
t.Fatalf("CredentialRef: got %q", got.CredentialRef)
|
|
}
|
|
}
|
|
|
|
func TestCapabilityFlags(t *testing.T) {
|
|
capabilities := CapabilityChangeRequest | CapabilityWebhook | CapabilityComment
|
|
|
|
if !capabilities.Has(CapabilityChangeRequest) {
|
|
t.Fatal("expected change request capability")
|
|
}
|
|
if !capabilities.Has(CapabilityWebhook) {
|
|
t.Fatal("expected webhook capability")
|
|
}
|
|
if !capabilities.Has(CapabilityComment) {
|
|
t.Fatal("expected comment capability")
|
|
}
|
|
if capabilities.Has(CapabilityChecks) {
|
|
t.Fatal("did not expect checks capability")
|
|
}
|
|
if capabilities.Has(0) {
|
|
t.Fatal("zero capability should not be supported")
|
|
}
|
|
}
|
|
|
|
func TestConfigSupportsCapability(t *testing.T) {
|
|
config := Config{
|
|
ID: ProviderForgejo,
|
|
Capabilities: CapabilityWebhook | CapabilityChecks,
|
|
}
|
|
|
|
if !config.Supports(CapabilityWebhook) {
|
|
t.Fatal("expected webhook support")
|
|
}
|
|
if !config.Supports(CapabilityChecks) {
|
|
t.Fatal("expected checks support")
|
|
}
|
|
if config.Supports(CapabilityChangeRequest) {
|
|
t.Fatal("did not expect change request support")
|
|
}
|
|
}
|