Skip to content

Commit

Permalink
Fix tests, rename to disassociated
Browse files Browse the repository at this point in the history
  • Loading branch information
idastambuk committed Oct 16, 2023
1 parent 2bd30f6 commit c46971c
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 28 deletions.
10 changes: 5 additions & 5 deletions pkg/server/test/property_value_aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type test struct {
name string
query string
isExpression bool
isUnassociated bool
isDisassociated bool
expectedMaxPages int
expectedMaxResults int
expectedDescribeTimeSeriesWithContextArgs *iotsitewise.DescribeTimeSeriesInput
Expand Down Expand Up @@ -196,10 +196,10 @@ func TestPropertyValueAggregate(t *testing.T) {
}
}

func TestPropertyValueAggregateWithUnassociatedStream(t *testing.T) {
func TestPropertyValueAggregateWithDisassociatedStream(t *testing.T) {
tc := test{
// an unassociated stream will return nil in DescribeTimeSeriesWithContext for assetId and propertyId
name: "query by property alias of an unassociated stream",
// an disassociated stream will return nil in DescribeTimeSeriesWithContext for assetId and propertyId
name: "query by property alias of an disassociated stream",
query: `{
"region":"us-west-2",
"propertyAlias":"/amazon/renton/1/rpm",
Expand All @@ -209,7 +209,7 @@ func TestPropertyValueAggregateWithUnassociatedStream(t *testing.T) {
expectedDescribeTimeSeriesWithContextArgs: &iotsitewise.DescribeTimeSeriesInput{Alias: Pointer("/amazon/renton/1/rpm")},
expectedMaxPages: 1,
expectedMaxResults: 0,
isUnassociated: true,
isDisassociated: true,
}

t.Run(tc.name, func(t *testing.T) {
Expand Down
28 changes: 14 additions & 14 deletions pkg/server/test/property_value_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ func Test_getPropertyValueHistoryFromAliasCaseTable(t *testing.T) {
}
}

func Test_getPropertyValueHistoryFromAliasCaseTableUnassociatedStream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-from-alias-unassociated.json"))
func Test_getPropertyValueHistoryFromAliasCaseTableDisassociatedStream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-from-alias-disassociated.json"))
propTimeSeries := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series-without-property.json"))
mockSw := &mocks.SitewiseClient{}
mockSw.On("BatchGetAssetPropertyValueHistoryPageAggregation", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&propVals, nil)
Expand Down Expand Up @@ -333,15 +333,15 @@ func Test_getPropertyValueHistoryFromAliasCaseTableUnassociatedStream(t *testing
require.Nil(t, err)

for i, dr := range qdr.Responses {
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-table-unassociated", i)
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-table-disassociated", i)
experimental.CheckGoldenJSONResponse(t, "../../testdata", fname, &dr, true)
}
}

func Test_getPropertyValueHistoryFromAliasCaseTimeSeries_associated_stream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-unassociated.json"))
func Test_getPropertyValueHistoryFromAliasCaseTimeSeries(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values.json"))
propDesc := testdata.GetIotSitewiseAssetProp(t, testDataRelativePath("describe-asset-property-avg-wind.json"))
propTimeSeries := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series-without-property.json"))
propTimeSeries := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series.json"))
mockSw := &mocks.SitewiseClient{}
mockSw.On("BatchGetAssetPropertyValueHistoryPageAggregation", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&propVals, nil)
mockSw.On("DescribeAssetPropertyWithContext", mock.Anything, mock.Anything).Return(&propDesc, nil)
Expand Down Expand Up @@ -377,12 +377,12 @@ func Test_getPropertyValueHistoryFromAliasCaseTimeSeries_associated_stream(t *te
require.Nil(t, err)

for i, dr := range qdr.Responses {
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-timeseries_with_associated_stream", i)
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-timeseries", i)
experimental.CheckGoldenJSONResponse(t, "../../testdata", fname, &dr, true)
}
}
func Test_getPropertyValueHistoryFromAliasCaseTimeSeries_unassociated_stream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-from-alias-unassociated.json"))
func Test_getPropertyValueHistoryFromAliasCaseTimeSeries_disassociated_stream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-from-alias-disassociated.json"))
propTimeSeries := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series-without-property.json"))
mockSw := &mocks.SitewiseClient{}
mockSw.On("BatchGetAssetPropertyValueHistoryPageAggregation", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&propVals, nil)
Expand Down Expand Up @@ -418,12 +418,12 @@ func Test_getPropertyValueHistoryFromAliasCaseTimeSeries_unassociated_stream(t *
require.Nil(t, err)

for i, dr := range qdr.Responses {
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-timeseries-unassociated", i)
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-timeseries-disassociated", i)
experimental.CheckGoldenJSONResponse(t, "../../testdata", fname, &dr, true)
}
}

func Test_getPropertyValueBooleanFromAliasWithAssociatedStream(t *testing.T) {
func Test_getPropertyValueBooleanFromAlias(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-boolean.json"))
propDesc := testdata.GetIotSitewiseAssetProp(t, testDataRelativePath("describe-asset-property-is-windy.json"))
propTimeSeries := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series.json"))
Expand Down Expand Up @@ -466,8 +466,8 @@ func Test_getPropertyValueBooleanFromAliasWithAssociatedStream(t *testing.T) {
}
}

func Test_getPropertyValueBooleanFromAliasWithUnassociatedStream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-boolean-unassociated.json"))
func Test_getPropertyValueBooleanFromAliasWithDisassociatedStream(t *testing.T) {
propVals := testdata.GetIoTSitewisePropHistoryVals(t, testDataRelativePath("property-history-values-boolean-disassociated.json"))
propTimeSeriesWithoutPropertyId := testdata.GetIoTSitewiseTimeSeries(t, testDataRelativePath("describe-time-series-without-property.json"))
mockSw := &mocks.SitewiseClient{}
mockSw.On("BatchGetAssetPropertyValueHistoryPageAggregation", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&propVals, nil)
Expand Down Expand Up @@ -502,7 +502,7 @@ func Test_getPropertyValueBooleanFromAliasWithUnassociatedStream(t *testing.T) {
require.Nil(t, err)

for i, dr := range qdr.Responses {
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-boolean-with-unassociated-stream", i)
fname := fmt.Sprintf("%s-%s.golden", "property-history-values-from-alias-boolean-with-disassociated-stream", i)
experimental.CheckGoldenJSONResponse(t, "../../testdata", fname, &dr, true)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/test/property_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func Test_property_value_query_by_alias_associated_stream(t *testing.T) {
},
)
}
func Test_property_value_query_by_alias_unassociated_stream(t *testing.T) {
func Test_property_value_query_by_alias_disassociated_stream(t *testing.T) {
mockSw := &mocks.SitewiseClient{}
mockSw.On("DescribeTimeSeriesWithContext", mock.Anything, mock.Anything).Return(&iotsitewise.DescribeTimeSeriesOutput{
Alias: Pointer("/amazon/renton/1/rpm"),
Expand Down
4 changes: 2 additions & 2 deletions pkg/sitewise/api/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func getAssetIdAndPropertyId(query models.AssetPropertyValueQuery, client client
if resp.AssetId != nil {
result.AssetIds = []string{*resp.AssetId}
} else {
// For unassociated streams with a propertyAlias
// For disassociated streams with a propertyAlias
result.AssetIds = []string{}
}
if resp.PropertyId != nil {
result.PropertyId = *resp.PropertyId
} else {
// For unassociated streams without a propertyAlias
// For disassociated streams without a propertyAlias
result.PropertyId = ""
}
}
Expand Down

This file was deleted.

0 comments on commit c46971c

Please sign in to comment.