2026-04-01 07:16:56 +00:00
|
|
|
package dev
|
|
|
|
|
|
|
|
|
|
import (
|
2026-04-24 18:51:16 +01:00
|
|
|
"reflect"
|
2026-04-01 07:16:56 +00:00
|
|
|
"testing"
|
|
|
|
|
|
2026-04-07 12:46:35 +01:00
|
|
|
"dappco.re/go/core/cli/pkg/cli"
|
2026-04-01 07:16:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestAddFileSyncCommand_Good(t *testing.T) {
|
|
|
|
|
root := &cli.Command{Use: "core"}
|
|
|
|
|
|
|
|
|
|
AddDevCommands(root)
|
|
|
|
|
|
|
|
|
|
syncCmd, _, err := root.Find([]string{"dev", "sync"})
|
2026-04-24 18:51:16 +01:00
|
|
|
mustNoError(t, err)
|
|
|
|
|
if syncCmd == nil {
|
|
|
|
|
t.Fatal("expected non-nil sync command")
|
|
|
|
|
}
|
2026-04-01 07:16:56 +00:00
|
|
|
|
|
|
|
|
yesFlag := syncCmd.Flags().Lookup("yes")
|
2026-04-24 18:51:16 +01:00
|
|
|
if yesFlag == nil {
|
|
|
|
|
t.Fatal("expected yes flag")
|
|
|
|
|
}
|
|
|
|
|
mustEqual(t, "y", yesFlag.Shorthand)
|
|
|
|
|
|
|
|
|
|
if syncCmd.Flags().Lookup("dry-run") == nil {
|
|
|
|
|
t.Fatal("expected dry-run flag")
|
|
|
|
|
}
|
|
|
|
|
if syncCmd.Flags().Lookup("push") == nil {
|
|
|
|
|
t.Fatal("expected push flag")
|
|
|
|
|
}
|
2026-04-01 07:16:56 +00:00
|
|
|
}
|
2026-04-01 08:13:14 +00:00
|
|
|
|
|
|
|
|
func TestSplitPatterns_Good(t *testing.T) {
|
|
|
|
|
patterns := splitPatterns("packages/core-*, apps/* ,services/*,")
|
2026-04-24 18:51:16 +01:00
|
|
|
want := []string{"packages/core-*", "apps/*", "services/*"}
|
|
|
|
|
if !reflect.DeepEqual(want, patterns) {
|
|
|
|
|
t.Fatalf("want %v, got %v", want, patterns)
|
|
|
|
|
}
|
2026-04-01 08:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMatchGlob_Good(t *testing.T) {
|
2026-04-24 18:51:16 +01:00
|
|
|
mustTrue(t, matchGlob("packages/core-xyz", "packages/core-*"))
|
|
|
|
|
mustTrue(t, matchGlob("packages/core-xyz", "*/core-*"))
|
|
|
|
|
mustTrue(t, matchGlob("a-b", "a?b"))
|
|
|
|
|
mustTrue(t, matchGlob("foo", "foo"))
|
|
|
|
|
mustFalse(t, matchGlob("core-other", "packages/*"))
|
|
|
|
|
mustFalse(t, matchGlob("abc", "[]"))
|
2026-04-01 08:13:14 +00:00
|
|
|
}
|