Skip to content

Commit

Permalink
fix: bump deps, fix lint errors (#190)
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 authored May 31, 2022
1 parent 217b606 commit 073cdb2
Show file tree
Hide file tree
Showing 35 changed files with 823 additions and 777 deletions.
24 changes: 12 additions & 12 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.sum|^.secrets.baseline$|_test.go|package-lock.json|.cra/.cveignore",
"lines": null
},
"generated_at": "2022-03-23T14:44:03Z",
"generated_at": "2022-05-27T20:50:10Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -152,79 +152,79 @@
"hashed_secret": "f0f9776696ad22d22eaac21090596c8ff9908a80",
"is_secret": false,
"is_verified": false,
"line_number": 459,
"line_number": 462,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "db4ba57216101b14d842d373717bea5849609df3",
"is_secret": false,
"is_verified": false,
"line_number": 538,
"line_number": 541,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "e117797422d35ce52f036963c7e9603e9955b5c7",
"is_secret": false,
"is_verified": false,
"line_number": 587,
"line_number": 590,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "8ec4981102569463be3512984154c66c098b92c5",
"is_secret": false,
"is_verified": false,
"line_number": 637,
"line_number": 640,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "4d6a6a4e27cfafab93e0487a9de1f26bdfeb8afb",
"is_secret": false,
"is_verified": false,
"line_number": 817,
"line_number": 820,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0d19d250028ff6865c70faea072729d1a888e9ae",
"is_secret": false,
"is_verified": false,
"line_number": 2192,
"line_number": 2202,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0ec6d150549780250a9772c06b619bcc46a0e560",
"is_secret": false,
"is_verified": false,
"line_number": 2379,
"line_number": 2541,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "e058a1c493ad749bd67d368340e9056ed1c2f3ed",
"is_secret": false,
"is_verified": false,
"line_number": 2392,
"line_number": 2554,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
"is_secret": false,
"is_verified": false,
"line_number": 3001,
"line_number": 3330,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "6452e7c5a42f97b00af1a210afc7d4de315e57ec",
"is_secret": false,
"is_verified": false,
"line_number": 4744,
"line_number": 5274,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -248,7 +248,7 @@
}
]
},
"version": "0.13.1+ibm.47.dss",
"version": "0.13.1+ibm.48.dss",
"word_list": {
"file": null,
"hash": null
Expand Down
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
Loading

0 comments on commit 073cdb2

Please sign in to comment.