Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anasmuhmd committed Nov 4, 2024
1 parent 4f603f9 commit cbab31d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
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"),
})
}

0 comments on commit cbab31d

Please sign in to comment.