Skip to content

Commit

Permalink
STAC-21039: Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
craffit committed May 13, 2024
1 parent fc8bc61 commit b609844
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions pkg/collector/corechecks/checkbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ func (c *CheckBase) CommonConfigure(senderManager sender.SenderManager, integrat
return err
}

// See if a collection interval was specified
if commonOptions.MinCollectionInterval > 0 {
// [STS] See if collection interval was specified
if commonOptions.CollectionInterval > 0 {
c.checkInterval = time.Duration(commonOptions.CollectionInterval) * time.Second
} else if commonOptions.MinCollectionInterval > 0 {
c.checkInterval = time.Duration(commonOptions.MinCollectionInterval) * time.Second
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/collector/corechecks/checkbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCommonConfigure(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 60*time.Second, mycheck.Interval())
mycheck.BuildID(1, []byte(customInstance), []byte(initConfig))
assert.Equal(t, string(mycheck.ID()), "test:foobar:a934df33209f45f4")
assert.Equal(t, "test:foobar:c4205343180505fb", string(mycheck.ID()))
mockSender.AssertExpectations(t)
}

Expand All @@ -81,7 +81,7 @@ func TestCommonConfigureCustomID(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 60*time.Second, mycheck.Interval())
mycheck.BuildID(1, []byte(customInstance), []byte(initConfig))
assert.Equal(t, string(mycheck.ID()), "test:foobar:a934df33209f45f4")
assert.Equal(t, "test:foobar:c4205343180505fb", string(mycheck.ID()))
mockSender.AssertExpectations(t)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@
package schema

import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"strings"
"testing"
)

func TestGenerateJSONSchemaIsInSync(t *testing.T) {
schemaJSON, err := GenerateJSONSchema()
require.NoError(t, err)
moduleName := fmt.Sprintf("%s/%s", getEnv("AGENT_GITHUB_ORG", "DataDog"), getEnv("AGENT_REPO_NAME", "datadog-agent"))
schemaWithModule := strings.ReplaceAll(string(GetDeviceProfileRcConfigJsonschema()), "DataDog/datadog-agent", moduleName)
assert.JSONEq(t, schemaWithModule, string(schemaJSON))
}

assert.JSONEq(t, string(GetDeviceProfileRcConfigJsonschema()), string(schemaJSON))
func getEnv(key string, dfault string) string {
value := os.Getenv(key)
if value == "" {
value = dfault
}
return value
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/StackVista/stackstate-agent/pkg/networkdevice/profile/profiledefinition/device-profile-rc-config",
"$id": "https://github.com/DataDog/datadog-agent/pkg/networkdevice/profile/profiledefinition/device-profile-rc-config",
"$ref": "#/$defs/DeviceProfileRcConfig",
"$defs": {
"DeviceMeta": {
Expand Down

0 comments on commit b609844

Please sign in to comment.