|
| 1 | +package mcs |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | +) |
| 6 | + |
| 7 | +func TestIsAvailable(t *testing.T) { |
| 8 | + // Test IsAvailable function |
| 9 | + available = true |
| 10 | + if !IsAvailable() { |
| 11 | + t.Error("Expected IsAvailable to return true when available is true") |
| 12 | + } |
| 13 | + |
| 14 | + available = false |
| 15 | + if IsAvailable() { |
| 16 | + t.Error("Expected IsAvailable to return false when available is false") |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +func TestMCSSchemeGroupVersion(t *testing.T) { |
| 21 | + // Test that MCSSchemeGroupVersion is initialized correctly |
| 22 | + if MCSSchemeGroupVersion.Group != "" { |
| 23 | + t.Errorf("Expected MCSSchemeGroupVersion.Group to be empty initially, got: %s", MCSSchemeGroupVersion.Group) |
| 24 | + } |
| 25 | + if MCSSchemeGroupVersion.Version != "" { |
| 26 | + t.Errorf("Expected MCSSchemeGroupVersion.Version to be empty initially, got: %s", MCSSchemeGroupVersion.Version) |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +func TestServiceExport(t *testing.T) { |
| 31 | + // Test ServiceExport creation |
| 32 | + namespace := "test-namespace" |
| 33 | + name := "test-service" |
| 34 | + labels := map[string]string{ |
| 35 | + "app": "test", |
| 36 | + } |
| 37 | + |
| 38 | + se := ServiceExport(namespace, name, labels) |
| 39 | + if se == nil { |
| 40 | + t.Error("Expected ServiceExport to be created, got nil") |
| 41 | + } |
| 42 | + |
| 43 | + if se.Name != name { |
| 44 | + t.Errorf("Expected ServiceExport name to be %s, got: %s", name, se.Name) |
| 45 | + } |
| 46 | + |
| 47 | + if se.Namespace != namespace { |
| 48 | + t.Errorf("Expected ServiceExport namespace to be %s, got: %s", namespace, se.Namespace) |
| 49 | + } |
| 50 | + |
| 51 | + if se.Labels["app"] != "test" { |
| 52 | + t.Errorf("Expected ServiceExport label 'app' to be 'test', got: %s", se.Labels["app"]) |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +func TestServiceExportList(t *testing.T) { |
| 57 | + // Test ServiceExportList creation |
| 58 | + seList := ServiceExportList() |
| 59 | + if seList == nil { |
| 60 | + t.Error("Expected ServiceExportList to be created, got nil") |
| 61 | + } |
| 62 | + |
| 63 | + if seList.Kind != "ServiceExportList" { |
| 64 | + t.Errorf("Expected ServiceExportList Kind to be 'ServiceExportList', got: %s", seList.Kind) |
| 65 | + } |
| 66 | +} |
0 commit comments