Skip to content

Commit

Permalink
add MutableCbsd.ValidateModel tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com>
  • Loading branch information
Jarosław Jaszczuk committed Jul 15, 2022
1 parent 4398d00 commit bf6d418
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions dp/cloud/go/services/dp/obsidian/models/validation_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package models_test

import (
"context"
"testing"

"magma/dp/cloud/go/services/dp/obsidian/to_pointer"

"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -99,3 +102,30 @@ func TestMutableCbsd_Validate(t *testing.T) {
})
}
}

func TestMutableCbsd_ValidateModel(t *testing.T) {
testData := []struct {
name string
data *models.MutableCbsd
expectedError string
}{{
name: "Should validate grant_redundancy false with carrier aggregation enabled",
data: b.NewMutableCbsdModelPayloadBuilder().
WithGrantRedundancy(to_pointer.Bool(false)).
WithCarrierAggregationEnabled(to_pointer.Bool(true)).
Payload,
expectedError: "grant_redundancy cannot be set to false when carrier_aggregation_enabled is enabled",
}, {
name: "Should validate max ibw mhz lesser than bandwidth mhz",
data: b.NewMutableCbsdModelPayloadBuilder().
WithMaxIbwMhz(5).WithBandwidth(10).Payload,
expectedError: "max_ibw_mhz cannot be less than bandwidth_mhz",
}}
c := context.TODO()
for _, tt := range testData {
t.Run(tt.name, func(t *testing.T) {
err := tt.data.ValidateModel(c)
assert.Contains(t, err.Error(), tt.expectedError)
})
}
}

0 comments on commit bf6d418

Please sign in to comment.