Skip to content

Commit

Permalink
Merge pull request #796 from Chamindu36/chamindu_3.2.X
Browse files Browse the repository at this point in the history
[3.2.X] [Integration Tests] Refactoring artifact paths stored in integration test resource storage
  • Loading branch information
Chamindu36 authored Oct 12, 2021
2 parents d1a96c7 + 855b06f commit d990a5f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
36 changes: 18 additions & 18 deletions import-export-cli/integration/devFirst_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ func TestImportAndExportAPIWithDocument(t *testing.T) {

projectPath, _ := filepath.Abs(projectName)
//Move doc file to created project
srcPathForDoc, _ := filepath.Abs(testutils.TestCase1DocPath)
destPathForDoc := projectPath + testutils.TestCase1DestPathSuffix
srcPathForDoc, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseDocPath)
destPathForDoc := projectPath + testutils.DevFirstUpdatedSampleCaseDestPathSuffix
base.Copy(srcPathForDoc, destPathForDoc)

//Move docMetaData file to created project
srcPathForDocMetadata, _ := filepath.Abs(testutils.TestCase1DocMetaDataPath)
destPathForDocMetaData := projectPath + testutils.TestCase1DestMetaDataPathSuffix
srcPathForDocMetadata, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseDocMetaDataPath)
destPathForDocMetaData := projectPath + testutils.DevFirstUpdatedSampleCaseDestMetaDataPathSuffix
base.Copy(srcPathForDocMetadata, destPathForDocMetaData)

//Import the project with Document
Expand Down Expand Up @@ -255,8 +255,8 @@ func TestImportAndExportAPIWithPngIcon(t *testing.T) {

//Move icon file to created project
projectPath, _ := filepath.Abs(projectName)
srcPathForIcon, _ := filepath.Abs(testutils.TestCase2PngPath)
destPathForIcon := projectPath + testutils.TestCase2DestPngPathSuffix
srcPathForIcon, _ := filepath.Abs(testutils.DevFirstSampleCasePngPath)
destPathForIcon := projectPath + testutils.DevFirstSampleCasePngPathSuffix
base.Copy(srcPathForIcon, destPathForIcon)

//Import the project with icon image(.png)
Expand Down Expand Up @@ -285,8 +285,8 @@ func TestImportAndExportAPIWithJpegImage(t *testing.T) {

//Move Image file to created project
projectPath, _ := filepath.Abs(projectName)
srcPathForImage, _ := filepath.Abs(testutils.TestCase2JpegPath)
destPathForImage := projectPath + testutils.TestCase2DestJpegPathSuffix
srcPathForImage, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseJpegPath)
destPathForImage := projectPath + testutils.DevFirstUpdatedSampleCaseDestJpegPathSuffix
base.Copy(srcPathForImage, destPathForImage)

//Import the project with icon image(.jpeg) provided
Expand Down Expand Up @@ -315,26 +315,26 @@ func TestUpdateDocAndImageOfAPIOfExistingAPI(t *testing.T) {

//Move doc file to created project
projectPath, _ := filepath.Abs(projectName)
srcPathForDoc, _ := filepath.Abs(testutils.TestCase2DocPath)
destPathForDoc := projectPath + testutils.TestCase2DestPathSuffix
srcPathForDoc, _ := filepath.Abs(testutils.DevFirstSampleCaseDocPath)
destPathForDoc := projectPath + testutils.DevFirstSampleCaseDestPathSuffix
base.Copy(srcPathForDoc, destPathForDoc)

//Move Image file to created project
srcPathForImage, _ := filepath.Abs(testutils.TestCase2JpegPath)
destPathForImage := projectPath + testutils.TestCase2DestJpegPathSuffix
srcPathForImage, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseJpegPath)
destPathForImage := projectPath + testutils.DevFirstUpdatedSampleCaseDestJpegPathSuffix
base.Copy(srcPathForImage, destPathForImage)

//Import the project with Document and image thumbnail
testutils.ValidateImportUpdateProjectNotAlreadyImported(t, args)

//Update doc file to created project
srcPathForDocUpdate, _ := filepath.Abs(testutils.TestCase1DocPath)
destPathForDocUpdate := projectPath + testutils.TestCase1DestPathSuffix
srcPathForDocUpdate, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseDocPath)
destPathForDocUpdate := projectPath + testutils.DevFirstUpdatedSampleCaseDestPathSuffix
base.Copy(srcPathForDocUpdate, destPathForDocUpdate)

//Update docMetaData file to created project
srcPathForDocMetadataUpdate, _ := filepath.Abs(testutils.TestCase1DocMetaDataPath)
destPathForDocMetaDataUpdate := projectPath + testutils.TestCase1DestMetaDataPathSuffix
srcPathForDocMetadataUpdate, _ := filepath.Abs(testutils.DevFirstUpdatedSampleCaseDocMetaDataPath)
destPathForDocMetaDataUpdate := projectPath + testutils.DevFirstUpdatedSampleCaseDestMetaDataPathSuffix
base.Copy(srcPathForDocMetadataUpdate, destPathForDocMetaDataUpdate)

//Update icon file to created project
Expand All @@ -343,8 +343,8 @@ func TestUpdateDocAndImageOfAPIOfExistingAPI(t *testing.T) {
t.Fatal(err)
}

srcPathForIcon, _ := filepath.Abs(testutils.TestCase2PngPath)
destPathForIcon := projectPath + testutils.TestCase2DestPngPathSuffix
srcPathForIcon, _ := filepath.Abs(testutils.DevFirstSampleCasePngPath)
destPathForIcon := projectPath + testutils.DevFirstSampleCasePngPathSuffix
base.Copy(srcPathForIcon, destPathForIcon)

base.WaitForIndexing()
Expand Down
6 changes: 3 additions & 3 deletions import-export-cli/integration/testutils/devFirst_testUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func ValidateAPIWithDocIsExported(t *testing.T, args *InitTestArgs, DevFirstDefa
relativePath := strings.ReplaceAll(exportedPath, ".zip", "")
base.Unzip(relativePath, exportedPath)

docPathOfExportedApi := relativePath + TestDefaultExtractedFileName + TestCase1DestPathSuffix
docPathOfExportedApi := relativePath + TestDefaultExtractedFileName + DevFirstUpdatedSampleCaseDestPathSuffix

//Check whether the file is available
isDocExported := base.IsFileAvailable(docPathOfExportedApi)
Expand All @@ -213,7 +213,7 @@ func ValidateAPIWithIconIsExported(t *testing.T, args *InitTestArgs, DevFirstDef
relativePath := strings.ReplaceAll(exportedPath, ".zip", "")
base.Unzip(relativePath, exportedPath)

iconPathOfExportedApi := relativePath + TestDefaultExtractedFileName + TestCase2DestPngPathSuffix
iconPathOfExportedApi := relativePath + TestDefaultExtractedFileName + DevFirstSampleCasePngPathSuffix

isIconExported := base.IsFileAvailable(iconPathOfExportedApi)
base.Log("Icon is Exported", isIconExported)
Expand All @@ -235,7 +235,7 @@ func ValidateAPIWithImageIsExported(t *testing.T, args *InitTestArgs, DevFirstDe
relativePath := strings.ReplaceAll(exportedPath, ".zip", "")
base.Unzip(relativePath, exportedPath)

imagePathOfExportedApi := relativePath + TestDefaultExtractedFileName + TestCase2DestJpegPathSuffix
imagePathOfExportedApi := relativePath + TestDefaultExtractedFileName + DevFirstUpdatedSampleCaseDestJpegPathSuffix
isIconExported := base.IsFileAvailable(imagePathOfExportedApi)
base.Log("Image is Exported", isIconExported)
assert.Equal(t, true, isIconExported, "Error while exporting API with icon")
Expand Down
20 changes: 10 additions & 10 deletions import-export-cli/integration/testutils/testConstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ const DefaultApictlTestAppName = "default-apictl-app"
const DevFirstDefaultAPIName = "SwaggerPetstoreNew"
const DevFirstSwagger2APIName = "PizzaShackAPI"
const DevFirstDefaultAPIVersion = "1.0.0"
const TestCase1DocPath = "testdata/TestArtifactDirectory/ArtifactSet1/testDoc.pdf"
const TestCase1DestPathSuffix = "/Docs/FileContents/testDoc.pdf"
const TestCase2DocPath = "testdata/TestArtifactDirectory/ArtifactSet2/mockPdf.pdf"
const TestCase2DestPathSuffix = "/Docs/FileContents/mockPdf.pdf"
const TestCase1DocMetaDataPath = "testdata/TestArtifactDirectory/ArtifactSet1/docs.yaml"
const TestCase1DestMetaDataPathSuffix = "/Docs/docs.yaml"
const TestCase2PngPath = "testdata/TestArtifactDirectory/ArtifactSet2/icon.png"
const TestCase2DestPngPathSuffix = "/Image/icon.png"
const TestCase2JpegPath = "testdata/TestArtifactDirectory/ArtifactSet2/icon.jpeg"
const TestCase2DestJpegPathSuffix = "/Image/icon.jpeg"
const DevFirstUpdatedSampleCaseDocPath = "testdata/TestArtifactDirectory/DevFirstUpdatedSampleCaseArtifacts/testDoc.pdf"
const DevFirstUpdatedSampleCaseDestPathSuffix = "/Docs/FileContents/testDoc.pdf"
const DevFirstSampleCaseDocPath = "testdata/TestArtifactDirectory/DevFirstSampleCase/mockPdf.pdf"
const DevFirstSampleCaseDestPathSuffix = "/Docs/FileContents/mockPdf.pdf"
const DevFirstUpdatedSampleCaseDocMetaDataPath = "testdata/TestArtifactDirectory/DevFirstUpdatedSampleCaseArtifacts/docs.yaml"
const DevFirstUpdatedSampleCaseDestMetaDataPathSuffix = "/Docs/docs.yaml"
const DevFirstSampleCasePngPath = "testdata/TestArtifactDirectory/DevFirstSampleCase/icon.png"
const DevFirstSampleCasePngPathSuffix = "/Image/icon.png"
const DevFirstUpdatedSampleCaseJpegPath = "testdata/TestArtifactDirectory/DevFirstUpdatedSampleCaseArtifacts/icon.jpeg"
const DevFirstUpdatedSampleCaseDestJpegPathSuffix = "/Image/icon.jpeg"
const TestDefaultExtractedFileName = "/SwaggerPetstoreNew-1.0.0"

// APIEndpointParamsFile : Endpoint URL api_params.yaml
Expand Down

0 comments on commit d990a5f

Please sign in to comment.