41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package configkit
|
|
|
|
import "testing"
|
|
|
|
func TestOverlayPublicValues(t *testing.T) {
|
|
if LayerOverlay != "overlay" {
|
|
t.Fatalf("LayerOverlay = %q", LayerOverlay)
|
|
}
|
|
for code, value := range map[Code]string{
|
|
CodeOverlayInvalid: "overlay.invalid",
|
|
CodeOverlayMissing: "overlay.missing",
|
|
CodeOverlayOutsideRoot: "overlay.outside_root",
|
|
CodeOverlayRepeated: "overlay.repeated",
|
|
CodeOverlayDirective: "overlay.directive",
|
|
CodeOverlayVersion: "overlay.version",
|
|
CodeOverlayLimitExceeded: "overlay.limit_exceeded",
|
|
} {
|
|
if string(code) != value {
|
|
t.Errorf("code = %q, want %q", code, value)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSourceInfoDestinationConversionsAndCopies(t *testing.T) {
|
|
destination := Keys("collections", "a/b", "0")
|
|
public := SourceInfo{ID: "source-1", Destination: destination}
|
|
internal := toEngineSourceInfo(public)
|
|
if internal.Destination.String() != destination.String() {
|
|
t.Fatalf("engine destination = %q, want %q", internal.Destination.String(), destination.String())
|
|
}
|
|
converted := fromEngineSourceInfo(internal)
|
|
if converted.Destination.String() != destination.String() {
|
|
t.Fatalf("public destination = %q, want %q", converted.Destination.String(), destination.String())
|
|
}
|
|
copy := cloneSourceInfo(converted)
|
|
copy.Destination = Path{}
|
|
if converted.Destination.String() != destination.String() {
|
|
t.Fatalf("source record destination changed through clone: %q", converted.Destination.String())
|
|
}
|
|
}
|