Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
feat(test): make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
paralta committed Aug 17, 2023
1 parent 66a27f0 commit bbba833
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
5 changes: 3 additions & 2 deletions e2e/abort_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package e2e

import (
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/openclarity/vmclarity/api/models"
"github.com/openclarity/vmclarity/pkg/shared/utils"
"time"
)

var _ = ginkgo.Describe("Aborting a scan", func() {

ginkgo.Context("which is running", func() {
ginkgo.It("should stop successfully", func(ctx ginkgo.SpecContext) {
ginkgo.By("applying a scan configuration")
Expand Down
5 changes: 3 additions & 2 deletions e2e/basic_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package e2e

import (
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/openclarity/vmclarity/api/models"
"github.com/openclarity/vmclarity/pkg/shared/utils"
"time"
)

var _ = ginkgo.Describe("Running a basic scan (only SBOM)", func() {

ginkgo.Context("which scans a docker container", func() {
ginkgo.It("should finish successfully", func(ctx ginkgo.SpecContext) {
ginkgo.By("waiting until test asset is found")
Expand Down
5 changes: 3 additions & 2 deletions e2e/default_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package e2e

import (
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/openclarity/vmclarity/api/models"
"github.com/openclarity/vmclarity/pkg/shared/utils"
"time"
)

var _ = ginkgo.Describe("Running a default scan (SBOM, vulnerabilities and exploits)", func() {

ginkgo.Context("which scans a docker container", func() {
ginkgo.It("should finish successfully", func(ctx ginkgo.SpecContext) {
ginkgo.By("applying a scan configuration")
Expand Down
5 changes: 3 additions & 2 deletions e2e/fail_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package e2e

import (
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/openclarity/vmclarity/api/models"
"github.com/openclarity/vmclarity/pkg/shared/utils"
"time"
)

var _ = ginkgo.Describe("Detecting scan failures", func() {

ginkgo.Context("when a scan stops without assets to scan", func() {
ginkgo.It("should detect failure reason successfully", func(ctx ginkgo.SpecContext) {
ginkgo.By("applying a scan configuration with not existing label")
Expand Down
6 changes: 4 additions & 2 deletions e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
package e2e

import (
"time"

"github.com/google/uuid"

"github.com/openclarity/vmclarity/api/models"
"github.com/openclarity/vmclarity/pkg/shared/utils"
"time"
)

const (
Expand All @@ -43,7 +45,7 @@ func GetDefaultScanConfig() models.ScanConfig {
return GetCustomScanConfig(
&DefaultScanFamiliesConfig,
DefaultScope,
600,
600, // nolint:gomnd
)
}

Expand Down
12 changes: 7 additions & 5 deletions e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ package e2e
import (
"context"
"fmt"
"os"
"strconv"
"testing"
"time"

"github.com/compose-spec/compose-go/cli"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/sirupsen/logrus"

"github.com/openclarity/vmclarity/e2e/testenv"
"github.com/openclarity/vmclarity/pkg/shared/backendclient"
"github.com/openclarity/vmclarity/pkg/shared/log"
"github.com/sirupsen/logrus"
"os"
"strconv"
"testing"
"time"
)

var (
Expand Down
17 changes: 11 additions & 6 deletions e2e/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ package testenv
import (
"context"
"fmt"
"net/url"
"strings"
"time"

"github.com/compose-spec/compose-go/cli"
"github.com/compose-spec/compose-go/types"
"github.com/docker/cli/cli/command"
cliflags "github.com/docker/cli/cli/flags"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
"github.com/pkg/errors"
"net/url"
"strings"
"time"
)

const (
Expand All @@ -42,6 +43,7 @@ type Environment struct {
reuse bool
}

// nolint:wrapcheck
func New(o *cli.ProjectOptions, reuse bool) (*Environment, error) {
project, err := cli.ProjectFromOptions(o)
if err != nil {
Expand Down Expand Up @@ -77,6 +79,7 @@ func New(o *cli.ProjectOptions, reuse bool) (*Environment, error) {
}, nil
}

// nolint:wrapcheck
func (e *Environment) Start(ctx context.Context) error {
if e.reuse {
return nil
Expand All @@ -94,13 +97,14 @@ func (e *Environment) Start(ctx context.Context) error {
Start: api.StartOptions{
Project: e.project,
Wait: true,
WaitTimeout: 10 * time.Minute,
WaitTimeout: 10 * time.Minute, // nolint:gomnd
Services: e.Services(),
},
}
return e.composer.Up(ctx, e.project, opts)
}

// nolint:wrapcheck
func (e *Environment) Stop(ctx context.Context) error {
if e.reuse {
return nil
Expand All @@ -116,6 +120,7 @@ func (e *Environment) Stop(ctx context.Context) error {
return e.composer.Down(ctx, e.project.Name, opts)
}

// nolint:wrapcheck
func (e *Environment) ServicesReady(ctx context.Context) (bool, error) {
services := e.Services()

Expand All @@ -131,7 +136,7 @@ func (e *Environment) ServicesReady(ctx context.Context) (bool, error) {
return false, err
}

// TODO(paralta) remove when grype-server-init service is removed
// TODO(paralta) remove when grype-server-init service is removed.
initServices := e.InitServices()
if len(services)-len(initServices) != len(ps) {
return false, nil
Expand All @@ -154,7 +159,7 @@ func (e *Environment) Services() []string {
return services
}

// TODO(paralta) remove when grype-server-init service is removed
// TODO(paralta) remove when grype-server-init service is removed.
func (e *Environment) InitServices() []string {
services := make([]string, 0, len(e.project.Services))
for _, srv := range e.project.Services {
Expand Down

0 comments on commit bbba833

Please sign in to comment.