diff options
Diffstat (limited to 'test/sdks_test.go')
-rw-r--r-- | test/sdks_test.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/test/sdks_test.go b/test/sdks_test.go index c00966f..1e3298f 100644 --- a/test/sdks_test.go +++ b/test/sdks_test.go @@ -60,6 +60,7 @@ func DisconnectSDKStateChange(t *testing.T, sCli *IOSockClient) { } func InitSdkDir() { + /*create sdk dir*/ sdkDir := os.Getenv(envXdtSdk) os.MkdirAll(sdkDir, 0755) currentDir, err := os.Getwd() @@ -72,29 +73,31 @@ func InitSdkDir() { } func RemoveSdk(t *testing.T, sdk xsapiv1.SDK, chSdks chan xsapiv1.SDK) { + t.Logf("remove sdk %v", sdk.ID) assert.Nil(t, HTTPCli.Delete("/sdks/"+sdk.ID, &sdk)) - sdkFromEvt := <-chSdks //Uninstalling + sdkFromEvt := <-chSdks //waiting for event Uninstalling assert.Equal(t, sdk.ID, sdkFromEvt.ID) assert.Equal(t, sdkFromEvt.Status, "Un-installing") - sdkFromEvt = <-chSdks //not installed + sdkFromEvt = <-chSdks //waiting for event not installed assert.Equal(t, sdkFromEvt.Status, "Not Installed") os.RemoveAll(path.Join(os.Getenv(envXdtSdk), sdk.Profile)) os.Remove(strings.Replace(sdk.URL, "file://", "", 1)) } func TestSdks(t *testing.T) { - cpt = 0 InitSdkDir() + /*get sdk list from sdk_latest.json*/ var sdkArray []xsapiv1.SDK assert.Nil(t, HTTPCli.Get("/sdks", &sdkArray)) _, err := os.Stat(path.Join(os.Getenv(envXdtSdk), "sdks_latest.json")) - time.Sleep(1000 * time.Millisecond) assert.Nil(t, err) + /*create channel fro SDK event*/ chSdks := make(chan xsapiv1.SDK) defer close(chSdks) ConnectSDKStateChange(t, sCli, chSdks) + /*checking startup installing of SDKs*/ for i := 0; i < len(sdkArray); i++ { re := regexp.MustCompile("^[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+-[0-9a-z]+$") assert.True(t, re.MatchString(sdkArray[i].ID)) @@ -105,15 +108,19 @@ func TestSdks(t *testing.T) { assert.Equal(t, sdkArray[i], sdk) var sdkRes xsapiv1.SDK + /*install sdk*/ + t.Logf("install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Installing") - sdkFromEvent := <-chSdks + sdkFromEvent := <-chSdks //waiting for installing event assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkFromEvent.Status, "Installing") + /*abort sdk install*/ + t.Logf("abort install sdk %v", sdk.Name) assert.Nil(t, HTTPCli.Post("/sdks/abortinstall", sdk, &sdkRes)) assert.Equal(t, sdkRes.Status, "Not Installed") - sdkFromEvent = <-chSdks + sdkFromEvent = <-chSdks //waiting for not installed status*/ assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, sdkRes.Status, sdkFromEvent.Status) } @@ -123,6 +130,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan InitSdkDir() var sdkRes xsapiv1.SDK assert.Nil(t, HTTPCli.Post("/sdks", sdkInstall, &sdkRes)) + t.Logf("Install fake sdk %v (force=%v)", sdkRes.Name, sdkInstall.Force) assert.Equal(t, sdkRes.Status, "Installing") sdkFromEvent := <-chSdks assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) @@ -132,6 +140,7 @@ func installFakeSdk(t *testing.T, sdkInstall xsapiv1.SDKInstallArgs, chSdks chan assert.Equal(t, sdkRes.ID, sdkFromEvent.ID) assert.Equal(t, "Installed", sdkFromEvent.Status) assert.Equal(t, sdkFromEvent.LastError, "") + t.Logf("Fake sdk %v installed", sdkFromEvent.Name) return sdkFromEvent } @@ -160,10 +169,17 @@ func TestSdksError(t *testing.T) { Filename: "", Force: false, } + t.Logf("error while installing sdk with no ID and no Filename") var sdkRes xsapiv1.SDK + /*error with no ID no filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) sdk.ID = "42885c24-374e-3ef0-9723-0c8a05191aa" + t.Logf("error while installing sdk with a fake id=%v", sdk.ID) + /*error with fake ID*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) + sdk.ID = "" sdk.Filename = "fake" + t.Logf("error while installing sdk with a fake filename=%v", sdk.Filename) + /*error with fake filename*/ assert.NotNil(t, HTTPCli.Post("/sdks", sdk, &sdkRes)) } |