MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestCmdWorkdirAddManualName

Function TestCmdWorkdirAddManualName

internal/app/workdir_test.go:32–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestCmdWorkdirAddManualName(t *testing.T) {
33 root := setupArchiveTestEnv(t)
34 db := reopenArchiveTestDB(t, root)
35
36 wdPath := filepath.Join(t.TempDir(), "myrepo")
37 if err := os.MkdirAll(wdPath, 0o755); err != nil {
38 t.Fatal(err)
39 }
40
41 if rc := cmdWorkdir([]string{"add", wdPath, "--name", "myrepo"}); rc != 0 {
42 t.Fatalf("add rc=%d", rc)
43 }
44 w, err := flowdb.GetWorkdir(db, wdPath)
45 if err != nil {
46 t.Fatalf("get: %v", err)
47 }
48 if !w.Name.Valid || w.Name.String != "myrepo" {
49 t.Errorf("name: got %+v", w.Name)
50 }
51 if w.GitRemote.Valid && w.GitRemote.String != "" {
52 t.Errorf("git_remote should be empty for non-git dir, got %+v", w.GitRemote)
53 }
54}
55
56func TestCmdWorkdirAddDetectsGitRemote(t *testing.T) {
57 root := setupArchiveTestEnv(t)

Callers

nothing calls this directly

Calls 4

GetWorkdirFunction · 0.92
setupArchiveTestEnvFunction · 0.85
reopenArchiveTestDBFunction · 0.85
cmdWorkdirFunction · 0.85

Tested by

no test coverage detected