Files
mesh-sdk/go/catalogue/user_namespaces_test.go
T

36 lines
1.6 KiB
Go

package catalogue
import (
"strings"
"testing"
)
// 1354/AC3: a contribution placed only where the machine reports the user namespaces capability (the name issue 1308 has
// the node-engine report) is accepted, and a misspelt name is still refused with today's words. The manifests are the
// shape of TestIfACapabilityNamesOneTheNodeEngineDetectsOnAnOfferedKindOnly (mesh-control 6c2a8d62
// internal/catalogue/seat_data_test.go:105), which stays in mesh-controller with the tests that read its other packages.
func TestIfACapabilityMayNameUserNamespaces(t *testing.T) {
const piece = `{"module":"power","contributions":[{"seat":"node-bar","kind":"block","if-capability":%q,"data":{"bar":"top","place":"status","shows":"battery"}}]}`
if _, err := ParseManifest([]byte(strings.Replace(piece, "%q", `"user-namespaces"`, 1))); err != nil {
t.Fatalf("if-capability user-namespaces was refused: %v", err)
}
for name, want := range map[string]string{
"user-namespace": "which no machine reports",
"userns": "which no machine reports",
"user_namespaces": "is not a capability's name",
} {
_, err := ParseManifest([]byte(strings.Replace(piece, "%q", `"`+name+`"`, 1)))
if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%s: accepted, or refused without today's words %q: %v", name, want, err)
}
}
if !oneOf(KnownCapabilities, "user-namespaces") {
t.Error("user-namespaces is not a known capability")
}
for _, name := range []string{"battery", "power-meter", "seat", "container-runtime"} {
if !oneOf(KnownCapabilities, name) {
t.Errorf("%s is no longer a known capability", name)
}
}
}