11import { doWithNewVal } from "~/vt/lib/tests/utils.ts" ;
22import { join } from "@std/path" ;
3- import sdk from "~/sdk.ts" ;
43import { runVtCommand } from "~/cmd/tests/utils.ts" ;
54import { assert , assertEquals , assertStringIncludes } from "@std/assert" ;
65import type ValTown from "@valtown/sdk" ;
76import { doWithTempDir } from "~/vt/lib/utils/misc.ts" ;
7+ import { createNewBranch , createValItem , deleteBranch } from "~/sdk.ts" ;
88
99Deno . test ( {
1010 name : "branch list command shows all branches" ,
@@ -15,12 +15,12 @@ Deno.test({
1515 const fullPath = join ( tmpDir , val . name ) ;
1616
1717 await t . step ( "create additional branches" , async ( ) => {
18- await sdk . vals . branches . create (
18+ await createNewBranch (
1919 val . id ,
2020 { name : "feature" , branchId : mainBranch . id } ,
2121 ) ;
2222
23- await sdk . vals . branches . create (
23+ await createNewBranch (
2424 val . id ,
2525 { name : "development" , branchId : mainBranch . id } ,
2626 ) ;
@@ -60,18 +60,18 @@ Deno.test({
6060 let featureBranch : ValTown . Vals . BranchListResponse ;
6161
6262 await t . step ( "create feature branch" , async ( ) => {
63- featureBranch = await sdk . vals . branches . create (
63+ featureBranch = await createNewBranch (
6464 val . id ,
65- { name : "feature-to-delete " , branchId : mainBranch . id } ,
65+ { name : "feature" , branchId : mainBranch . id } ,
6666 ) ;
6767
68- await sdk . vals . files . create (
68+ await createValItem (
6969 val . id ,
7070 {
71- path : "feaature.ts " ,
72- content : "console.log('Feature branch file');" ,
73- branch_id : featureBranch . id ,
74- type : "script " ,
71+ path : "feature.txt " ,
72+ branchId : featureBranch . id ,
73+ content : "feature branch file" ,
74+ type : "file " ,
7575 } ,
7676 ) ;
7777 } ) ;
@@ -85,25 +85,25 @@ Deno.test({
8585 "verify feature branch exists in branch list" ,
8686 async ( ) => {
8787 const [ listOutput ] = await runVtCommand ( [ "branch" ] , fullPath ) ;
88- assertStringIncludes ( listOutput , "feature-to-delete " ) ;
88+ assertStringIncludes ( listOutput , "feature" ) ;
8989 } ,
9090 ) ;
9191
9292 await t . step ( "delete the feature branch" , async ( ) => {
9393 const [ deleteOutput ] = await runVtCommand (
94- [ "branch" , "-D" , "feature-to-delete " ] ,
94+ [ "branch" , "-D" , "feature" ] ,
9595 fullPath ,
9696 ) ;
9797 assertStringIncludes (
9898 deleteOutput ,
99- "Branch 'feature-to-delete ' has been deleted" ,
99+ "Branch 'feature' has been deleted" ,
100100 ) ;
101101 } ) ;
102102
103103 await t . step ( "verify branch is no longer listed" , async ( ) => {
104104 const [ listOutput ] = await runVtCommand ( [ "branch" ] , fullPath ) ;
105105 assert (
106- ! listOutput . includes ( "feature-to-delete " ) ,
106+ ! listOutput . includes ( "feature" ) ,
107107 "deleted branch should not appear in branch list" ,
108108 ) ;
109109 } ) ;
@@ -180,29 +180,29 @@ Deno.test({
180180 let tempBranch : ValTown . Vals . BranchListResponse ;
181181
182182 await t . step ( "create temporary branch" , async ( ) => {
183- tempBranch = await sdk . vals . branches . create (
183+ tempBranch = await createNewBranch (
184184 val . id ,
185- { name : "temp-branch " , branchId : mainBranch . id } ,
185+ { name : "temp" , branchId : mainBranch . id } ,
186186 ) ;
187187
188- await sdk . vals . files . create (
188+ await createValItem (
189189 val . id ,
190190 {
191- path : "temp.ts " ,
192- content : "// Temporary file" ,
193- branch_id : tempBranch . id ,
194- type : "script " ,
191+ path : "temp.txt " ,
192+ branchId : tempBranch . id ,
193+ content : "temp branch file" ,
194+ type : "file " ,
195195 } ,
196196 ) ;
197197 } ) ;
198198
199199 await t . step ( "clone and checkout to temporary branch" , async ( ) => {
200200 await runVtCommand ( [ "clone" , val . name , "--no-editor-files" ] , tmpDir ) ;
201- await runVtCommand ( [ "checkout" , "temp-branch " ] , fullPath ) ;
201+ await runVtCommand ( [ "checkout" , "temp" ] , fullPath ) ;
202202 } ) ;
203203
204204 await t . step ( "delete the branch remotely" , async ( ) => {
205- await sdk . vals . branches . delete ( val . id , tempBranch . id ) ;
205+ await deleteBranch ( val . id , tempBranch . id ) ;
206206 } ) ;
207207
208208 await t . step ( "run branch command and verify warning" , async ( ) => {
0 commit comments