@@ -108,6 +108,54 @@ func TestBranch_CreateCmdWithRestore(t *testing.T) {
108108 c .Assert (buf .String (), qt .JSONEquals , res )
109109}
110110
111+ func TestBranch_CreateCmdWithRestoreNoSize (t * testing.T ) {
112+ c := qt .New (t )
113+
114+ var buf bytes.Buffer
115+ format := printer .JSON
116+ p := printer .NewPrinter (& format )
117+ p .SetResourceOutput (& buf )
118+
119+ org := "planetscale"
120+ db := "planetscale"
121+ branch := "development"
122+
123+ res := & ps.DatabaseBranch {Name : branch }
124+
125+ svc := & mock.DatabaseBranchesService {
126+ CreateFn : func (ctx context.Context , req * ps.CreateDatabaseBranchRequest ) (* ps.DatabaseBranch , error ) {
127+ c .Assert (req .Name , qt .Equals , branch )
128+ c .Assert (req .Database , qt .Equals , db )
129+ c .Assert (req .Region , qt .Equals , "us-east" )
130+ c .Assert (req .Organization , qt .Equals , org )
131+ c .Assert (req .BackupID , qt .Equals , "somebackupid" )
132+ c .Assert (req .ClusterSize , qt .Equals , "PS-10" )
133+
134+ return res , nil
135+ },
136+ }
137+
138+ ch := & cmdutil.Helper {
139+ Printer : p ,
140+ Config : & config.Config {
141+ Organization : org ,
142+ },
143+ Client : func () (* ps.Client , error ) {
144+ return & ps.Client {
145+ DatabaseBranches : svc ,
146+ }, nil
147+ },
148+ }
149+
150+ cmd := CreateCmd (ch )
151+ cmd .SetArgs ([]string {db , branch , "--region" , "us-east" , "--restore" , "somebackupid" })
152+ err := cmd .Execute ()
153+
154+ c .Assert (err , qt .IsNil )
155+ c .Assert (svc .CreateFnInvoked , qt .IsTrue )
156+ c .Assert (buf .String (), qt .JSONEquals , res )
157+ }
158+
111159func TestBranch_CreateCmdWithSeedData (t * testing.T ) {
112160 c := qt .New (t )
113161
0 commit comments