@@ -17,13 +17,13 @@ func TestRepositoryCreate(t *testing.T) {
17
17
WithRepository (t , "repository-create" , SetupEmptyRepo , func (t * testing.T , repo * repository.Repository , user * UserActions ) {
18
18
// Create an environment
19
19
env := user .CreateEnvironment ("Test Create" , "Testing repository create" )
20
-
20
+
21
21
// Verify environment was created properly
22
22
assert .NotNil (t , env )
23
23
assert .NotEmpty (t , env .ID )
24
24
assert .Equal (t , "Test Create" , env .State .Title )
25
25
assert .NotEmpty (t , env .Worktree )
26
-
26
+
27
27
// Verify worktree was created
28
28
_ , err := os .Stat (env .Worktree )
29
29
assert .NoError (t , err )
@@ -35,17 +35,17 @@ func TestRepositoryGet(t *testing.T) {
35
35
t .Parallel ()
36
36
WithRepository (t , "repository-get" , SetupEmptyRepo , func (t * testing.T , repo * repository.Repository , user * UserActions ) {
37
37
ctx := context .Background ()
38
-
38
+
39
39
// Create an environment
40
40
env := user .CreateEnvironment ("Test Get" , "Testing repository get" )
41
-
41
+
42
42
// Get the environment using repository directly
43
43
retrieved , err := repo .Get (ctx , user .dag , env .ID )
44
44
require .NoError (t , err )
45
45
assert .NotNil (t , retrieved )
46
46
assert .Equal (t , env .ID , retrieved .ID )
47
47
assert .Equal (t , env .State .Title , retrieved .State .Title )
48
-
48
+
49
49
// Test getting non-existent environment
50
50
_ , err = repo .Get (ctx , user .dag , "non-existent-env" )
51
51
assert .Error (t , err )
@@ -57,16 +57,16 @@ func TestRepositoryList(t *testing.T) {
57
57
t .Parallel ()
58
58
WithRepository (t , "repository-list" , SetupEmptyRepo , func (t * testing.T , repo * repository.Repository , user * UserActions ) {
59
59
ctx := context .Background ()
60
-
60
+
61
61
// Create two environments
62
62
env1 := user .CreateEnvironment ("Environment 1" , "First test environment" )
63
63
env2 := user .CreateEnvironment ("Environment 2" , "Second test environment" )
64
-
64
+
65
65
// List should return at least 2
66
66
envs , err := repo .List (ctx )
67
67
require .NoError (t , err )
68
68
assert .GreaterOrEqual (t , len (envs ), 2 )
69
-
69
+
70
70
// Verify the environments are in the list
71
71
var foundIDs []string
72
72
for _ , e := range envs {
@@ -82,20 +82,20 @@ func TestRepositoryDelete(t *testing.T) {
82
82
t .Parallel ()
83
83
WithRepository (t , "repository-delete" , SetupEmptyRepo , func (t * testing.T , repo * repository.Repository , user * UserActions ) {
84
84
ctx := context .Background ()
85
-
85
+
86
86
// Create an environment
87
87
env := user .CreateEnvironment ("Test Delete" , "Testing repository delete" )
88
88
worktreePath := env .Worktree
89
89
envID := env .ID
90
-
90
+
91
91
// Delete it
92
92
err := repo .Delete (ctx , envID )
93
93
require .NoError (t , err )
94
-
94
+
95
95
// Verify it's gone
96
96
_ , err = repo .Get (ctx , user .dag , envID )
97
97
assert .Error (t , err )
98
-
98
+
99
99
// Verify worktree is deleted
100
100
_ , err = os .Stat (worktreePath )
101
101
assert .True (t , os .IsNotExist (err ))
@@ -107,22 +107,22 @@ func TestRepositoryCheckout(t *testing.T) {
107
107
t .Parallel ()
108
108
WithRepository (t , "repository-checkout" , SetupEmptyRepo , func (t * testing.T , repo * repository.Repository , user * UserActions ) {
109
109
ctx := context .Background ()
110
-
110
+
111
111
// Create an environment and add content
112
112
env := user .CreateEnvironment ("Test Checkout" , "Testing repository checkout" )
113
113
user .FileWrite (env .ID , "test.txt" , "test content" , "Add test file" )
114
-
114
+
115
115
// Checkout the environment branch in the source repo
116
- branch , err := repo .Checkout (ctx , env .ID )
116
+ branch , err := repo .Checkout (ctx , env .ID , "" )
117
117
require .NoError (t , err )
118
118
assert .NotEmpty (t , branch )
119
-
119
+
120
120
// Verify we're on the correct branch
121
121
currentBranch , err := repository .RunGitCommand (ctx , repo .SourcePath (), "branch" , "--show-current" )
122
122
require .NoError (t , err )
123
123
// Branch name could be either env.ID or cu-env.ID depending on the logic
124
124
actualBranch := strings .TrimSpace (currentBranch )
125
- assert .True (t , actualBranch == env .ID || actualBranch == "cu-" + env .ID ,
125
+ assert .True (t , actualBranch == env .ID || actualBranch == "cu-" + env .ID ,
126
126
"Expected branch to be %s or cu-%s, got %s" , env .ID , env .ID , actualBranch )
127
127
})
128
- }
128
+ }
0 commit comments