Skip to content

Commit

Permalink
fix: bump deps, fix lint errors
Browse files Browse the repository at this point in the history
This commit includes the following changes:
1. Some dependencies were bumped to newer versions
2. The build will now lint-check integration tests and examples
3. Changes to allow the int tests and examples to lint-check cleanly
  • Loading branch information
padamstx committed May 27, 2022
1 parent 217b606 commit 59c187e
Show file tree
Hide file tree
Showing 34 changed files with 808 additions and 754 deletions.
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# Makefile to build the project
GO=go
LINT=golangci-lint
GOSEC=gosec

COVERAGE = -coverprofile=coverage.txt -covermode=atomic

all: tidy test lint
travis-ci: test-cov lint scan-gosec tidy

test:
go test `go list ./...`
${GO} test `${GO} list ./...`

test-cov:
go test `go list ./...` ${COVERAGE}
${GO} test `${GO} list ./...` ${COVERAGE}

test-int:
go test `go list ./...` -tags=integration
${GO} test `${GO} list ./...` -tags=integration

test-int-cov:
go test `go list ./...` -tags=integration ${COVERAGE}
${GO} test `${GO} list ./...` -tags=integration ${COVERAGE}

lint:
golangci-lint run
${LINT} run --build-tags=integration,examples

scan-gosec:
gosec ./...
${GOSEC} ./...

tidy:
go mod tidy
${GO} mod tidy
35 changes: 18 additions & 17 deletions casemanagementv1/case_management_v1_examples_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build examples
// +build examples

/**
Expand Down Expand Up @@ -47,24 +48,25 @@ import (
// in a configuration file and then:
// export IBM_CREDENTIALS_FILE=<name of configuration file>
//
const externalConfigFile = "../case_management.env"

var (
caseManagementService *casemanagementv1.CaseManagementV1
config map[string]string
configLoaded bool = false
caseNumber string
attachmentID string
resourceCRN string
)

func shouldSkipTest() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
var _ = Describe(`CaseManagementV1 Examples Tests`, func() {
const externalConfigFile = "../case_management.env"

var (
caseManagementService *casemanagementv1.CaseManagementV1
config map[string]string
configLoaded bool = false
caseNumber string
attachmentID string
resourceCRN string
)

var shouldSkipTest = func() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
}
}
}

var _ = Describe(`CaseManagementV1 Examples Tests`, func() {
Describe(`External configuration`, func() {
It("Successfully load the configuration", func() {
var err error
Expand Down Expand Up @@ -366,8 +368,7 @@ var _ = Describe(`CaseManagementV1 Examples Tests`, func() {
if result != nil {
defer result.Close()
buf := new(bytes.Buffer)
buf.ReadFrom(result)

_, _ = buf.ReadFrom(result)
fmt.Println(buf.String())
}

Expand Down
63 changes: 30 additions & 33 deletions casemanagementv1/case_management_v1_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration
// +build integration

/**
Expand Down Expand Up @@ -35,54 +36,50 @@ import (
common "github.com/IBM/platform-services-go-sdk/common"
)

const externalConfigFile = "../case_management.env"
var _ = Describe("Case Management - Integration Tests", func() {
const externalConfigFile = "../case_management.env"

var (
service *casemanagementv1.CaseManagementV1
err error
var (
service *casemanagementv1.CaseManagementV1
err error

configLoaded bool = false
config map[string]string

caseNumber string
commentValue = "Test comment"
caseNumber string
commentValue = "Test comment"

// Configured resource CRN to use in tests.
resourceCRN string
// Configured resource CRN to use in tests.
resourceCRN string

// Model instances needed by the tests.
resourcePayload []casemanagementv1.ResourcePayload
watchlistPayload *casemanagementv1.Watchlist
)
// Model instances needed by the tests.
resourcePayload []casemanagementv1.ResourcePayload
watchlistPayload *casemanagementv1.Watchlist
)

func shouldSkipTest() {
if !configLoaded {
var shouldSkipTest = func() {
Skip("External configuration is not available, skipping...")
}
}

var _ = Describe("Case Management - Integration Tests", func() {
It("Successfully load the configuration", func() {
var config map[string]string
if _, fileErr := os.Stat(externalConfigFile); fileErr == nil {
os.Setenv("IBM_CREDENTIALS_FILE", externalConfigFile)
config, _ = core.GetServiceProperties(casemanagementv1.DefaultServiceName)
if len(config) > 0 {
configLoaded = true
}

if configLoaded {

}
_, err = os.Stat(externalConfigFile)
if err != nil {
Skip("External configuration file not found, skipping tests: " + err.Error())
}

if !configLoaded {
Skip("External configuration could not be loaded, skipping...")
os.Setenv("IBM_CREDENTIALS_FILE", externalConfigFile)
config, err = core.GetServiceProperties(casemanagementv1.DefaultServiceName)
if err != nil {
Skip("Error loading service properties, skipping tests: " + err.Error())
}
serviceURL := config["URL"]
if serviceURL == "" {
Skip("Unable to load service URL configuration property, skipping tests")
}

resourceCRN = config["RESOURCE_CRN"]
if resourceCRN == "" {
Skip("RESOURCE_CRN configuration property not found, skipping...")
}
Expect(resourceCRN).ToNot(BeEmpty())

shouldSkipTest = func() {}

// Initialize required model instances.
resourcePayload = []casemanagementv1.ResourcePayload{casemanagementv1.ResourcePayload{
Expand Down
47 changes: 25 additions & 22 deletions catalogmanagementv1/catalog_management_v1_examples_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build examples
// +build examples

/**
Expand Down Expand Up @@ -45,30 +46,31 @@ import (
// in a configuration file and then:
// export IBM_CREDENTIALS_FILE=<name of configuration file>
//
const externalConfigFile = "../catalog_mgmt.env"

var (
catalogManagementService *catalogmanagementv1.CatalogManagementV1
config map[string]string
configLoaded bool = false
accountID string
bearerToken string
gitAuthTokenForPublicRepo string
catalogID string
offeringID string
clusterID string
objectID string
offeringInstanceID string
versionLocatorID string
)

func shouldSkipTest() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
var _ = Describe(`CatalogManagementV1 Examples Tests`, func() {
const externalConfigFile = "../catalog_mgmt.env"

var (
catalogManagementService *catalogmanagementv1.CatalogManagementV1
config map[string]string
configLoaded bool = false
accountID string
bearerToken string
gitAuthTokenForPublicRepo string
catalogID string
offeringID string
clusterID string
objectID string
offeringInstanceID string
versionLocatorID string
)

var shouldSkipTest = func() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
}
}
}

var _ = Describe(`CatalogManagementV1 Examples Tests`, func() {
Describe(`External configuration`, func() {
It("Successfully load the configuration", func() {
var err error
Expand Down Expand Up @@ -105,7 +107,7 @@ var _ = Describe(`CatalogManagementV1 Examples Tests`, func() {

catalogManagementServiceOptions := &catalogmanagementv1.CatalogManagementV1Options{}

catalogManagementService, err = catalogmanagementv1.NewCatalogManagementV1UsingExternalConfig(catalogManagementServiceOptions)
catalogManagementService, err := catalogmanagementv1.NewCatalogManagementV1UsingExternalConfig(catalogManagementServiceOptions)

if err != nil {
panic(err)
Expand Down Expand Up @@ -652,6 +654,7 @@ var _ = Describe(`CatalogManagementV1 Examples Tests`, func() {
catalogID,
offeringID,
"roks",
"",
)
getOfferingUpdatesOptions.Version = core.StringPtr("0.0.2")
getOfferingUpdatesOptions.ClusterID = &clusterID
Expand Down
49 changes: 25 additions & 24 deletions catalogmanagementv1/catalog_management_v1_old_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build integration2
// +build integration2

/**
Expand Down Expand Up @@ -32,32 +33,32 @@ import (
. "github.com/onsi/gomega"
)

const (
externalConfigFile = "../catalog_mgmt.env"
expectedShortDesc = "test"
expectedURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s"
expectedOfferingsURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings"
fakeName = "bogus"
fakeVersionLocator = "bogus.bogus"
expectedOfferingName = "test-offering"
expectedOfferingURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings/%s"
)

var (
service *catalogmanagementv1.CatalogManagementV1
gitToken string
accountID string
configLoaded bool = false
expectedLabel = fmt.Sprintf("integration-test-%d", time.Now().Unix())
)

func shouldSkipTest() {
if !configLoaded {
Skip("External configuration is not available, skipping...")
var _ = Describe("Catalog Management - Integration Tests (OLD)", func() {
const (
externalConfigFile = "../catalog_mgmt.env"
expectedShortDesc = "test"
expectedURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s"
expectedOfferingsURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings"
fakeName = "bogus"
fakeVersionLocator = "bogus.bogus"
expectedOfferingName = "test-offering"
expectedOfferingURL = "https://cm.globalcatalog.test.cloud.ibm.com/api/v1-beta/catalogs/%s/offerings/%s"
)

var (
service *catalogmanagementv1.CatalogManagementV1
gitToken string
accountID string
configLoaded bool = false
expectedLabel = fmt.Sprintf("integration-test-%d", time.Now().Unix())
)

var shouldSkipTest = func() {
if !configLoaded {
Skip("External configuration is not available, skipping...")
}
}
}

var _ = Describe("Catalog Management - Integration Tests (OLD)", func() {
It("Successfully load the configuration", func() {
if _, err := os.Stat(externalConfigFile); err == nil {
if err = os.Setenv("IBM_CREDENTIALS_FILE", externalConfigFile); err == nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build examples
// +build examples

/**
Expand Down Expand Up @@ -48,40 +49,39 @@ import (
// in a configuration file and then:
// export IBM_CREDENTIALS_FILE=<name of configuration file>
//
const externalConfigFile = "../configuration_governance.env"

var (
configurationGovernanceService *configurationgovernancev1.ConfigurationGovernanceV1
config map[string]string
configLoaded bool = false

// Test-related configuration properties.
accountID string
serviceName string
enterpriseScopeID string
subacctScopeID string

transactionID string = uuid.New().String()
)

// Global variables to hold various values shared between operations
var (
ruleIDLink string
ruleToUpdateLink *configurationgovernancev1.Rule
ruleToUpdateEtagLink string

attachmentIDLink string
attachmentToUpdateLink *configurationgovernancev1.Attachment
attachmentToUpdateEtagLink string
)

func shouldSkipTest() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
var _ = Describe(`ConfigurationGovernanceV1 Examples Tests`, func() {
const externalConfigFile = "../configuration_governance.env"

var (
configurationGovernanceService *configurationgovernancev1.ConfigurationGovernanceV1
config map[string]string
configLoaded bool = false

// Test-related configuration properties.
accountID string
serviceName string
enterpriseScopeID string
subacctScopeID string
)

// Global variables to hold various values shared between operations
var (
ruleIDLink string
ruleToUpdateLink *configurationgovernancev1.Rule
ruleToUpdateEtagLink string

attachmentIDLink string
attachmentToUpdateLink *configurationgovernancev1.Attachment
attachmentToUpdateEtagLink string
)

var shouldSkipTest = func() {
if !configLoaded {
Skip("External configuration is not available, skipping tests...")
}
}
}

var _ = Describe(`ConfigurationGovernanceV1 Examples Tests`, func() {
Describe(`External configuration`, func() {
It("Successfully load the configuration", func() {
var err error
Expand Down
Loading

0 comments on commit 59c187e

Please sign in to comment.