Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failing tests #258

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/plugins/crowdstrike/data-sources/falcon_cspm_ioms.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ The data source supports the following execution arguments:
data falcon_cspm_ioms {
# limit the number of queried items
#
# Required integer.
# For example:
size = 42
# Optional integer.
# Default value:
limit = 10
}
```
2 changes: 1 addition & 1 deletion docs/plugins/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"member_cid"
],
"arguments": [
"size"
"limit"
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions internal/crowdstrike/data_falcon_cspm_ioms.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ func makeFalconCspmIomsDataSource(loader ClientLoaderFn) *plugin.DataSource {
Args: &dataspec.RootSpec{
Attrs: []*dataspec.AttrSpec{
{
Name: "size",
Name: "limit",
Type: cty.Number,
Constraints: constraint.Integer | constraint.RequiredNonNull,
Constraints: constraint.Integer,
DefaultVal: cty.NumberIntVal(10),
Doc: "limit the number of queried items",
},
},
Expand All @@ -43,7 +44,7 @@ func fetchFalconCspmIomsData(loader ClientLoaderFn) plugin.RetrieveDataFunc {
Detail: err.Error(),
}}
}
size, _ := params.Args.GetAttrVal("size").AsBigFloat().Int64()
size, _ := params.Args.GetAttrVal("limit").AsBigFloat().Int64()
apiParams := cspm_registration.NewGetConfigurationDetectionsParams().WithDefaults()
apiParams.SetLimit(&size)
apiParams.Context = ctx
Expand Down
17 changes: 3 additions & 14 deletions internal/crowdstrike/data_falcon_cspm_ioms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *CrowdstrikeCspmIomsTestSuite) TestBasic() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.plugin.DataSources["falcon_cspm_ioms"].Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
s.Require().Nil(diags)
Expand Down Expand Up @@ -131,7 +131,7 @@ func (s *CrowdstrikeCspmIomsTestSuite) TestPayloadErrors() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.plugin.DataSources["falcon_cspm_ioms"].Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
diagtest.Asserts{{
Expand All @@ -153,7 +153,7 @@ func (s *CrowdstrikeCspmIomsTestSuite) TestError() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.plugin.DataSources["falcon_cspm_ioms"].Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
diagtest.Asserts{{
Expand All @@ -162,14 +162,3 @@ func (s *CrowdstrikeCspmIomsTestSuite) TestError() {
diagtest.DetailContains("something went wrong"),
}}.AssertMatch(s.T(), diags, nil)
}

func (s *CrowdstrikeCspmIomsTestSuite) TestMissingArgs() {
plugintest.NewTestDecoder(
s.T(),
s.plugin.DataSources["falcon_cspm_ioms"].Args,
).Decode([]diagtest.Assert{
diagtest.IsError,
diagtest.SummaryEquals("Missing required attribute"),
diagtest.DetailContains("size"),
})
}
11 changes: 0 additions & 11 deletions internal/crowdstrike/data_falcon_discover_host_details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,3 @@ func (s *CrowdstrikeDiscoverHostDetailsTestSuite) TestError() {
diagtest.DetailContains("something went wrong"),
}}.AssertMatch(s.T(), diags, nil)
}

func (s *CrowdstrikeDiscoverHostDetailsTestSuite) TestMissingArgs() {
plugintest.NewTestDecoder(
s.T(),
s.Datasource().Args,
).Decode([]diagtest.Assert{
diagtest.IsError,
diagtest.SummaryEquals("Missing required attribute"),
diagtest.DetailContains("limit"),
})
}