66 "github.com/stretchr/testify/assert"
77 "github.com/stretchr/testify/require"
88
9- "github.com/openmeterio/openmeter/openmeter/app"
109 "github.com/openmeterio/openmeter/openmeter/taxcode"
1110 taxcodetestutils "github.com/openmeterio/openmeter/openmeter/taxcode/testutils"
1211 "github.com/openmeterio/openmeter/openmeter/testutils"
@@ -21,11 +20,15 @@ func TestTaxCodeService(t *testing.T) {
2120 ns := testutils .NameGenerator .Generate ().Key
2221
2322 t .Run ("SystemManaged" , func (t * testing.T ) {
24- // Create a system-managed tax code via GetOrCreateByAppMapping.
25- tc , err := env .Service .GetOrCreateByAppMapping (t .Context (), taxcode.GetOrCreateByAppMappingInput {
23+ // Create a system-managed tax code by explicitly setting the annotation.
24+ name := testutils .NameGenerator .Generate ()
25+ tc , err := env .Service .CreateTaxCode (t .Context (), taxcode.CreateTaxCodeInput {
2626 Namespace : ns ,
27- AppType : app .AppTypeStripe ,
28- TaxCode : "txcd_99999999" ,
27+ Key : name .Key ,
28+ Name : name .Name ,
29+ Annotations : models.Annotations {
30+ taxcode .AnnotationKeyManagedBy : taxcode .AnnotationValueManagedBySystem ,
31+ },
2932 })
3033 require .NoError (t , err )
3134 assert .True (t , tc .IsManagedBySystem ())
@@ -73,6 +76,20 @@ func TestTaxCodeService(t *testing.T) {
7376 assert .Equal (t , "updated name" , updated .Name )
7477 })
7578
79+ t .Run ("UpdateAnnotationsSucceeds" , func (t * testing.T ) {
80+ updated , err := env .Service .UpdateTaxCode (t .Context (), taxcode.UpdateTaxCodeInput {
81+ NamespacedID : models.NamespacedID {Namespace : ns , ID : tc .ID },
82+ Name : tc .Name ,
83+ Annotations : models.Annotations {
84+ taxcode .AnnotationKeyManagedBy : taxcode .AnnotationValueManagedBySystem ,
85+ "schema_version" : 1 ,
86+ },
87+ })
88+ require .NoError (t , err )
89+ assert .True (t , updated .IsManagedBySystem ())
90+ assert .Equal (t , float64 (1 ), updated .Annotations ["schema_version" ])
91+ })
92+
7693 t .Run ("DeleteSucceeds" , func (t * testing.T ) {
7794 // Create a fresh one to delete (the one above was updated, still valid).
7895 name2 := testutils .NameGenerator .Generate ()
0 commit comments