@@ -19,7 +19,7 @@ func TestRegisterEvent_InvalidParams(t *testing.T) {
1919 tPkg , _ := a .AddPackage (& Package {Type : PkgTypeOther , URL : "http://sample.url/pkg" , Version : "12.1.0" , ApplicationID : tApp .ID })
2020 tChannel , _ := a .AddChannel (& Channel {Name : "test_channel" , Color : "blue" , ApplicationID : tApp .ID , PackageID : null .StringFrom (tPkg .ID )})
2121 tGroup , _ := a .AddGroup (& Group {Name : "group1" , ApplicationID : tApp .ID , ChannelID : null .StringFrom (tChannel .ID ), PolicyUpdatesEnabled : true , PolicySafeMode : true , PolicyPeriodInterval : "15 minutes" , PolicyMaxUpdatesPerPeriod : 2 , PolicyUpdateTimeout : "60 minutes" })
22- tInstance , _ := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
22+ tInstance , _ := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
2323
2424 err := a .RegisterEvent (uuid .New ().String (), tApp .ID , tGroup .ID , EventUpdateComplete , ResultSuccessReboot , "" , "" )
2525 assert .Equal (t , ErrInvalidInstance , err )
@@ -33,7 +33,7 @@ func TestRegisterEvent_InvalidParams(t *testing.T) {
3333 err = a .RegisterEvent (tInstance .ID , tApp .ID , tGroup .ID , EventUpdateDownloadStarted , ResultSuccess , "" , "" )
3434 assert .Equal (t , ErrNoUpdateInProgress , err )
3535
36- _ , _ = a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
36+ _ , _ = a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
3737
3838 err = a .RegisterEvent (tInstance .ID , tApp .ID , tGroup .ID , 1000 , ResultSuccess , "" , "" )
3939 assert .Equal (t , ErrInvalidEventTypeOrResult , err )
@@ -51,10 +51,10 @@ func TestRegisterEvent_TriggerEventConsequences(t *testing.T) {
5151 tPkg , _ := a .AddPackage (& Package {Type : PkgTypeOther , URL : "http://sample.url/pkg" , Version : "12.1.0" , ApplicationID : tApp .ID })
5252 tChannel , _ := a .AddChannel (& Channel {Name : "test_channel" , Color : "blue" , ApplicationID : tApp .ID , PackageID : null .StringFrom (tPkg .ID )})
5353 tGroup , _ := a .AddGroup (& Group {Name : "group1" , ApplicationID : tApp .ID , ChannelID : null .StringFrom (tChannel .ID ), PolicyUpdatesEnabled : true , PolicySafeMode : true , PolicyPeriodInterval : "15 minutes" , PolicyMaxUpdatesPerPeriod : 2 , PolicyUpdateTimeout : "60 minutes" })
54- tInstance , _ := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
55- tInstance2 , _ := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.2" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
54+ tInstance , _ := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
55+ tInstance2 , _ := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.2" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
5656
57- _ , err := a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
57+ _ , err := a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
5858 assert .NoError (t , err )
5959
6060 err = a .RegisterEvent (tInstance .ID , "{" + tApp .ID + "}" , tGroup .ID , EventUpdateDownloadStarted , ResultSuccess , "" , "" )
@@ -77,7 +77,7 @@ func TestRegisterEvent_TriggerEventConsequences(t *testing.T) {
7777 instance , _ = a .GetInstance (tInstance .ID , tApp .ID )
7878 assert .Equal (t , null .IntFrom (int64 (InstanceStatusComplete )), instance .Application .Status )
7979
80- _ , err = a .GetUpdatePackage (tInstance2 .ID , "" , "10.0.0.2" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
80+ _ , err = a .GetUpdatePackage (Instance { ID : tInstance2 .ID , IP : "10.0.0.2" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
8181 assert .NoError (t , err )
8282
8383 err = a .RegisterEvent (tInstance2 .ID , tApp .ID , tGroup .ID , EventUpdateComplete , ResultFailed , "" , "" )
@@ -97,9 +97,9 @@ func TestRegisterEvent_TriggerEventConsequences_FirstUpdateAttemptFailed(t *test
9797 tPkg , _ := a .AddPackage (& Package {Type : PkgTypeOther , URL : "http://sample.url/pkg" , Version : "12.1.0" , ApplicationID : tApp .ID })
9898 tChannel , _ := a .AddChannel (& Channel {Name : "test_channel" , Color : "blue" , ApplicationID : tApp .ID , PackageID : null .StringFrom (tPkg .ID )})
9999 tGroup , _ := a .AddGroup (& Group {Name : "group1" , ApplicationID : tApp .ID , ChannelID : null .StringFrom (tChannel .ID ), PolicyUpdatesEnabled : true , PolicySafeMode : true , PolicyPeriodInterval : "15 minutes" , PolicyMaxUpdatesPerPeriod : 2 , PolicyUpdateTimeout : "60 minutes" })
100- tInstance , _ := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
100+ tInstance , _ := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
101101
102- _ , err := a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
102+ _ , err := a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
103103 assert .NoError (t , err )
104104
105105 err = a .RegisterEvent (tInstance .ID , tApp .ID , tGroup .ID , EventUpdateComplete , ResultFailed , "" , "" )
@@ -115,10 +115,10 @@ func TestRegisterEvent_CheckSuccessResult(t *testing.T) {
115115 defer a .Close ()
116116
117117 performUpdate := func (tApp * Application , tGroup * Group , resultType int ) {
118- tInstance , err := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
118+ tInstance , err := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
119119 assert .NoError (t , err )
120120
121- _ , err = a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
121+ _ , err = a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
122122 assert .NoError (t , err )
123123
124124 err = a .RegisterEvent (tInstance .ID , "{" + tApp .ID + "}" , tGroup .ID , EventUpdateDownloadStarted , ResultSuccess , "" , "" )
@@ -159,10 +159,10 @@ func TestRegisterEvent_CheckFlatcarSuccessResult(t *testing.T) {
159159 defer a .Close ()
160160
161161 performUpdate := func (tApp * Application , tGroup * Group , resultType , expectedInstanceStatus int ) {
162- tInstance , err := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
162+ tInstance , err := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
163163 assert .NoError (t , err )
164164
165- _ , err = a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
165+ _ , err = a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
166166 assert .NoError (t , err )
167167
168168 err = a .RegisterEvent (tInstance .ID , "{" + tApp .ID + "}" , tGroup .ID , EventUpdateDownloadStarted , ResultSuccess , "11.0.0" , "" )
@@ -207,10 +207,10 @@ func TestRegisterEvent_CheckFlatcarIgnoredUpdate(t *testing.T) {
207207 tGroup , _ := a .AddGroup (& Group {Name : "group9" , ApplicationID : tApp .ID , ChannelID : null .StringFrom (tChannel .ID ), PolicyUpdatesEnabled : true , PolicySafeMode : false , PolicyPeriodInterval : "15 minutes" , PolicyMaxUpdatesPerPeriod : 2 , PolicyUpdateTimeout : "60 minutes" })
208208
209209 performUpdate := func (previousVersion string ) {
210- tInstance , err := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
210+ tInstance , err := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
211211 assert .NoError (t , err )
212212
213- _ , err = a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
213+ _ , err = a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
214214 assert .NoError (t , err )
215215
216216 err = a .RegisterEvent (tInstance .ID , "{" + tApp .ID + "}" , tGroup .ID , EventUpdateDownloadStarted , ResultSuccess , previousVersion , "" )
@@ -247,9 +247,9 @@ func TestRegisterEvent_GetEvent(t *testing.T) {
247247 tPkg , _ := a .AddPackage (& Package {Type : PkgTypeOther , URL : "http://sample.url/pkg" , Version : "12.1.0" , ApplicationID : tApp .ID })
248248 tChannel , _ := a .AddChannel (& Channel {Name : "test_channel" , Color : "blue" , ApplicationID : tApp .ID , PackageID : null .StringFrom (tPkg .ID )})
249249 tGroup , _ := a .AddGroup (& Group {Name : "group1" , ApplicationID : tApp .ID , ChannelID : null .StringFrom (tChannel .ID ), PolicyUpdatesEnabled : true , PolicySafeMode : true , PolicyPeriodInterval : "15 minutes" , PolicyMaxUpdatesPerPeriod : 2 , PolicyUpdateTimeout : "60 minutes" })
250- tInstance , _ := a .RegisterInstance (uuid .New ().String (), "" , "10.0.0.1" , "1.0.0" , tApp .ID , tGroup .ID , "" , "" )
250+ tInstance , _ := a .RegisterInstance (Instance { ID : uuid .New ().String (), IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "1.0.0" ) )
251251
252- _ , err := a .GetUpdatePackage (tInstance .ID , "" , "10.0.0.1" , "12.0.0" , tApp .ID , tGroup .ID , "" , "" )
252+ _ , err := a .GetUpdatePackage (Instance { ID : tInstance .ID , IP : "10.0.0.1" }, NewInstanceApplication ( tApp .ID , tGroup .ID , "12.0.0" ) )
253253 assert .NoError (t , err )
254254
255255 _ , err = a .GetEvent (tInstance .ID , tApp .ID , time .Now ())
0 commit comments