Skip to content

Commit

Permalink
Merge pull request #22 from shaior/talm2
Browse files Browse the repository at this point in the history
Restructure ztp folder to improve design
  • Loading branch information
mcornea authored Oct 3, 2023
2 parents b106869 + 05b43f0 commit 2ead379
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 358 deletions.
167 changes: 0 additions & 167 deletions tests/argocd/argocd_suite_test.go

This file was deleted.

45 changes: 0 additions & 45 deletions tests/argocd/internal/argocdparams/argocdparams.go

This file was deleted.

70 changes: 70 additions & 0 deletions tests/gitopsztp/argocd/argocd_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package argocd

import (
"runtime"
"testing"

. "github.com/onsi/ginkgo/v2"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
"github.com/openshift-kni/eco-goinfra/pkg/namespace"
"github.com/openshift-kni/eco-goinfra/pkg/polarion"
"github.com/openshift-kni/eco-goinfra/pkg/reporter"
"github.com/openshift-kni/eco-gosystem/tests/gitopsztp/argocd/internal/argocdhelper"
"github.com/openshift-kni/eco-gosystem/tests/gitopsztp/argocd/internal/argocdparams"
_ "github.com/openshift-kni/eco-gosystem/tests/gitopsztp/argocd/tests"
"github.com/openshift-kni/eco-gosystem/tests/gitopsztp/internal/gitopsztphelper"
. "github.com/openshift-kni/eco-gosystem/tests/internal/inittools"

. "github.com/onsi/gomega"
)

var _, currentFile, _, _ = runtime.Caller(0)

func TestArgocd(t *testing.T) {
_, reporterConfig := GinkgoConfiguration()
reporterConfig.JUnitReport = GeneralConfig.GetJunitReportPath(currentFile)

RegisterFailHandler(Fail)
// Stop ginkgo complaining about slow tests

RunSpecs(t, "Argocd Suite", reporterConfig)
}

var _ = BeforeSuite(func() {
// API clients must be initialized first since they will be used later
err := gitopsztphelper.InitializeClients()
Expect(err).ToNot(HaveOccurred())

namespace := namespace.NewBuilder(gitopsztphelper.HubAPIClient, argocdparams.ZtpTestNamespace)

// Delete and re-create the namespace to start with a clean state
if namespace.Exists() {
err = namespace.DeleteAndWait(argocdparams.DefaultTimeout)
Expect(err).ToNot(HaveOccurred())
}

_, err = namespace.Create()
Expect(err).ToNot(HaveOccurred())
})

var _ = AfterSuite(func() {
// Restore the original Argocd configuration after the tests are completed
err := argocdhelper.ResetArgocdGitDetails()
Expect(err).ToNot(HaveOccurred())

// Delete the ztp namespace
err = namespace.NewBuilder(gitopsztphelper.HubAPIClient, argocdparams.ZtpTestNamespace).Delete()
Expect(err).ToNot(HaveOccurred())
})

var _ = JustAfterEach(func() {
reporter.ReportIfFailed(
CurrentSpecReport(), GeneralConfig.GetDumpFailedTestReportLocation(currentFile),
GeneralConfig.ReportsDirAbsPath, argocdhelper.ReporterNamespacesToDump,
argocdhelper.ReporterCRDsToDump, clients.SetScheme)
})

var _ = ReportAfterSuite("", func(report Report) {
polarion.CreateReport(
report, GeneralConfig.GetPolarionReportPath(), GeneralConfig.PolarionTCPrefix)
})
Loading

0 comments on commit 2ead379

Please sign in to comment.