package unpack import ( "testing" "edge-infra.dev/pkg/f8n/warehouse/oci/layer" ) func TestOptions(t *testing.T) { tcs := map[string]struct { input []Option valid bool }{ "WithInfraNamespace without infra layer": { []Option{WithInfraNamespace("foo")}, false, }, "WithInfraNamespace and ForLayerKeys": { []Option{WithInfraNamespace("foo"), ForLayerKeys(layer.Infra.String())}, true, }, "WithInfraNamespace and ForLayerTypes": { []Option{WithInfraNamespace("foo"), ForLayerTypes(layer.Infra)}, true, }, "ForLayerKeys and ForLayerTypes are mutually exclusive": { []Option{ForLayerKeys("prometheus", "runtime"), ForLayerTypes("runtime")}, false, }, } for name, tc := range tcs { t.Run(name, func(t *testing.T) { _, err := makeOptions(tc.input...) switch { case tc.valid && err != nil: t.Error("unexpected error", err) case !tc.valid && err == nil: t.Error("expected an error") } }) } }