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

AWS Mainframe Modernisation Service Deployment Resource #35408

Merged
merged 157 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
0b34fbf
Initial pass at m2 service environment resource
drewtul Jan 10, 2024
c515493
Initial pass on docs
drewtul Jan 11, 2024
2061c98
Fix doc issues, break tests up so basic test is minimal as possible
drewtul Jan 11, 2024
2a29453
Missing example param in docs
drewtul Jan 11, 2024
2183b89
Merge branch 'f-mainframe-service-client' into f-mainframe-environmen…
drewtul Jan 11, 2024
587b7cd
Test update and fixes
drewtul Jan 11, 2024
58ec004
Add force_update
drewtul Jan 11, 2024
220924b
Merge branch 'f-mainframe-service-client' into f-mainframe-environmen…
drewtul Jan 15, 2024
2cc3aac
Add changelog entry
drewtul Jan 15, 2024
ed51d73
Fix formatting of terraform in tests
drewtul Jan 15, 2024
05280d3
Fix blank lines in docs
drewtul Jan 15, 2024
715efc3
Fix hcl formatting in docs
drewtul Jan 15, 2024
0c4066d
Fix hcl formatting in docs
drewtul Jan 15, 2024
cf27fd8
Fix test resource formatting
drewtul Jan 15, 2024
3014e15
Remove trailing spaces in test hcl
drewtul Jan 15, 2024
3864f04
Fix more formatting in tests now it parses
drewtul Jan 15, 2024
f66e119
Remove trailing spaces in test hcl
drewtul Jan 15, 2024
872cc3b
Remove trailing spaces in test hcl
drewtul Jan 15, 2024
8018f1a
Fix import check failing
drewtul Jan 15, 2024
adda841
Fix linting warnings
drewtul Jan 15, 2024
e1404da
Remove trailing empty lines
drewtul Jan 15, 2024
f618bea
Fix naming and adjust default timeouts in docs to match code.
drewtul Jan 15, 2024
76082c6
Merge branch 'main' of github.com:hashicorp/terraform-provider-aws in…
drewtul Jan 16, 2024
95a6a88
Iniitial Commit
Jan 16, 2024
5eaade5
Migrate to framework from old SDK.
drewtul Jan 17, 2024
d9ae753
Actually send desired capacity in update if changed.
drewtul Jan 17, 2024
8f5b244
Merge branch 'main' of github.com:hashicorp/terraform-provider-aws in…
drewtul Jan 17, 2024
6ca4f77
Fix imports
drewtul Jan 17, 2024
491780d
Fix caps on FSX/EFS
drewtul Jan 17, 2024
0d9d774
Missing blank line
drewtul Jan 17, 2024
bbe17d8
FSX -> Fsx
drewtul Jan 17, 2024
27cd942
Tags not being set correctly.
drewtul Jan 17, 2024
297a728
Initial version of aws_m2_application resource
drewtul Jan 17, 2024
2d14a4f
Order properties per docs.
drewtul Jan 18, 2024
2b959d2
Change to SingleNestedBlock for definition, it's not a list.
drewtul Jan 18, 2024
5140925
Update states for application lifecycle
drewtul Jan 18, 2024
dd3d4bb
Fsx should be FSx
drewtul Jan 18, 2024
1e22179
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Jan 18, 2024
b67192e
Add Accpt tests
Jan 18, 2024
0f6c9f5
Initial pass at deployment resource
drewtul Jan 19, 2024
743ee05
Set start to `false` for the disappears test as we can't delete an ap…
drewtul Jan 19, 2024
e0505c5
Fix errors from checks
drewtul Jan 19, 2024
bf23e11
Sort Imports.
drewtul Jan 19, 2024
f7ae118
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Jan 19, 2024
e69650e
Basic docs for deployment.
drewtul Jan 19, 2024
e520859
Fix linting issue in test terraform.
drewtul Jan 19, 2024
232c017
Fix linting issue in test docs.
drewtul Jan 19, 2024
79d1a13
Spelling error.
drewtul Jan 19, 2024
cf947fc
Fix imports.
drewtul Jan 19, 2024
c9b641d
Remove check for property that doesn't exist.
drewtul Jan 19, 2024
c1fa425
Remove check for property that doesn't exist.
drewtul Jan 19, 2024
800040d
Whitespace.
drewtul Jan 19, 2024
7e63607
Unused function.
drewtul Jan 19, 2024
43f08b4
Unused param.
drewtul Jan 19, 2024
76686b1
Unused return value.
drewtul Jan 19, 2024
a89ff1d
Missing section in docs.
drewtul Jan 19, 2024
8e0355b
Superfluous if.
drewtul Jan 19, 2024
c409886
Don't hard code region.
drewtul Jan 19, 2024
cbca232
Remove requires replace.
drewtul Jan 19, 2024
c073afb
Check if application is running before attempting to stop it so we ca…
drewtul Jan 22, 2024
8e8432d
Update tests for deployment.
drewtul Jan 22, 2024
eea83f2
fmt
drewtul Jan 22, 2024
167a8a1
lint.
drewtul Jan 22, 2024
8b27202
Change engine to 3.7.0 as this version works for starting update of d…
drewtul Jan 23, 2024
29ac069
Use 3.9.0 as it's the latest engine and correctly deploys the demo app.
drewtul Jan 23, 2024
1d56a5d
Remove generated guidance
drewtul Jan 24, 2024
b8ab90f
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Jan 24, 2024
f66ddd7
Add changelog
drewtul Jan 27, 2024
fc8c8fa
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Jan 27, 2024
12a7095
Add changelog
drewtul Jan 27, 2024
e1d43e0
adding application and deployment
Jan 28, 2024
c756f30
Dont Auto Flex
Feb 5, 2024
9c8cab9
Merge branch 'main' of github.com:hashicorp/terraform-provider-aws in…
drewtul Feb 6, 2024
37973b4
Merge branch 'main' of github.com:hashicorp/terraform-provider-aws in…
drewtul Feb 6, 2024
b995f9b
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Feb 6, 2024
239c4d5
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 6, 2024
1534673
Merge branch 'f-mainframe-environment-resource' of github.com:drewtul…
drewtul Feb 6, 2024
2468c59
Try Auto Flex
Feb 11, 2024
f155ba3
Use autoflex where possible here
drewtul Feb 19, 2024
ad5158d
import formatting
drewtul Feb 19, 2024
d961826
tweaks on review comments, add more tests
drewtul Feb 21, 2024
e03a0c8
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Feb 21, 2024
15da14a
Additional testing and related changes
drewtul Feb 21, 2024
b2705d1
Revert changes to description, it doesn't need replacement nor is it …
drewtul Feb 21, 2024
0f675ef
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 21, 2024
4b2bc2c
Merge branch 'main' of github.com:hashicorp/terraform-provider-aws in…
drewtul Feb 21, 2024
e35814b
Merge branch 'f-mainframe-environment-resource' of github.com:drewtul…
drewtul Feb 21, 2024
d1effde
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Feb 21, 2024
7d2db1f
Merge branch 'f-mainframe-application-resource' of github.com:drewtul…
drewtul Feb 21, 2024
f22df4c
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 21, 2024
622d245
fmt test tf
drewtul Feb 21, 2024
fe52719
Replace EndpointID with ServiceID
drewtul Feb 21, 2024
dc9bebd
Whitespace
drewtul Feb 21, 2024
7930982
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Feb 21, 2024
c2b28cc
Fix test tf formatting.
drewtul Feb 21, 2024
90a8da3
Use correct constant
drewtul Feb 21, 2024
c1fa4a2
Use correct constant
drewtul Feb 21, 2024
b300194
Merge branch 'f-mainframe-environment-resource' into f-mainframe-appl…
drewtul Feb 21, 2024
9ac0644
whitespace
drewtul Feb 21, 2024
e118ccd
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 21, 2024
1199696
Use correct constant
drewtul Feb 21, 2024
c4e1418
Remove format string
drewtul Feb 21, 2024
f58cbac
Remove format string
drewtul Feb 21, 2024
748bc77
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 21, 2024
dad573b
Fix prefixes for tests
drewtul Feb 21, 2024
cdbb18f
Merge branch 'f-mainframe-application-resource' into f-mainframe-depl…
drewtul Feb 21, 2024
2d6529f
Revert "Try Auto Flex"
ewbankkit Mar 21, 2024
e8164cd
Revert "Dont Auto Flex"
ewbankkit Mar 21, 2024
a2f227b
Revert "adding application and deployment"
ewbankkit Mar 21, 2024
528c323
Revert "Add Accpt tests"
ewbankkit Mar 21, 2024
c962d85
Revert "Iniitial Commit"
ewbankkit Mar 21, 2024
80a4a2c
Merge commit 'c962d8542fbc4d710c63ac4b0d68dda4b32bbe78' into HEAD
ewbankkit Mar 21, 2024
6587508
Merge branch 'main' into HEAD
ewbankkit Mar 21, 2024
e332f81
'export_test.go' -> 'exports_test.go'.
ewbankkit Mar 21, 2024
7f366bd
r/aws_m2_environment: Some renaming.
ewbankkit Mar 21, 2024
93837ee
r/aws_m2_environment: More renaming.
ewbankkit Mar 21, 2024
319a7b5
r/aws_m2_environment: Tidy up Create.
ewbankkit Mar 21, 2024
d1dad85
r/aws_m2_environment: Tidy up Delete.
ewbankkit Mar 21, 2024
af88268
r/aws_m2_environment: Change 'expandStorageConfigurations'.
ewbankkit Mar 21, 2024
aecf060
r/aws_m2_environment: Tidy up Read.
ewbankkit Mar 22, 2024
dc9034a
r/aws_m2_environment: Tidy up Update.
ewbankkit Mar 22, 2024
1ad86b2
r/aws_m2_environment: Tidy up acceptance tests.
ewbankkit Mar 22, 2024
d3187f1
r/aws_m2_environment: 'description' is not Computed.
ewbankkit Mar 22, 2024
024cad0
r/aws_m2_environment: Tweak 'TestAccM2Environment_basic'.
ewbankkit Mar 22, 2024
4df6c6b
Acceptance test output:
ewbankkit Mar 22, 2024
05400c6
Add 'OnceAWeekWindow' custom type.
ewbankkit Mar 22, 2024
9ed0b41
r/aws_m2_environment: Use 'OnceAWeekWindowType'.
ewbankkit Mar 22, 2024
0898f13
r/aws_m2_environment: UseStateForUnknown for 'load_balancer_arn'.
ewbankkit Mar 22, 2024
a86e54a
Tweak 'TestAccM2Environment_tags'.
ewbankkit Mar 22, 2024
1f3dc42
Acceptance test output:
ewbankkit Mar 22, 2024
e7196ad
Tidy up 'TestAccM2Environment_full' and 'TestAccM2Environment_update'.
ewbankkit Mar 22, 2024
01379fd
Acceptance test output:
ewbankkit Mar 22, 2024
adda8eb
AutoFlEx: Silently skip Smithy union types (#36508).
ewbankkit Mar 22, 2024
c0fa452
r/aws_m2_environment: Taint on 'waitEnvironmentCreated' failure.
ewbankkit Mar 22, 2024
a4de048
Fix 'flattenStorageConfigurations' to prevent crash in 'NewListNested…
ewbankkit Mar 22, 2024
7322d1d
Correct acceptance test configuration indentation.
ewbankkit Mar 22, 2024
dc649e0
Acceptance test output:
ewbankkit Mar 22, 2024
6d53cb0
Merge commit 'dc649e07b3e60c790e5d37f626f927979819a21b' into HEAD
ewbankkit Mar 22, 2024
6d71e05
Merge branch 'main' into HEAD
ewbankkit Mar 22, 2024
1201017
r/aws_m2_application: Some renaming.
ewbankkit Mar 24, 2024
92aed5a
r/aws_m2_application: Use AutoFlEx.
ewbankkit Mar 24, 2024
031974e
Simplify.
ewbankkit Mar 24, 2024
d8ef0f9
r/aws_m2_application: Demo application from 'https://docs.aws.amazon.…
ewbankkit Mar 24, 2024
da938b4
r/aws_m2_application: Tidy up acceptance tests.
ewbankkit Mar 24, 2024
b8b1a2b
r/aws_m2_application: Corrections.
ewbankkit Mar 25, 2024
ef871a5
r/aws_m2_application: Tidy up acceptance tests.
ewbankkit Mar 25, 2024
42fefc1
Acceptance test output:
ewbankkit Mar 25, 2024
8e414e1
Merge commit '42fefc1b795af621091b335baef6c0477e5bf00c' into HEAD
ewbankkit Mar 25, 2024
cd81508
Merge branch 'main' into HEAD
ewbankkit Mar 25, 2024
837e491
r/aws_m2_deployment: Tidy up.
ewbankkit Mar 25, 2024
93a973c
r/aws_m2_deployment: Tidy up acceptance tests.
ewbankkit Mar 25, 2024
bd8bdf4
r/aws_m2_deployment: Tidy up acceptance tests.
ewbankkit Mar 25, 2024
c027620
Acceptance test output:
ewbankkit Mar 25, 2024
73641d5
Fix terrafmt error.
ewbankkit Mar 25, 2024
5aae6b8
Run 'make gen'.
ewbankkit Mar 25, 2024
8fd8ea4
Fix golangci-lint 'unparam'.
ewbankkit Mar 25, 2024
b4288be
Fix 'TestOnceAWeekWindowStringSemanticEquals'.
ewbankkit Mar 25, 2024
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
3 changes: 3 additions & 0 deletions .changelog/35311.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_m2_environment
```
3 changes: 3 additions & 0 deletions .changelog/35399.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_m2_application
```
3 changes: 3 additions & 0 deletions .changelog/35408.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_m2_deployment
```
16 changes: 15 additions & 1 deletion internal/framework/flex/auto_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,24 @@ func (expander autoExpander) nestedObjectCollection(ctx context.Context, vFrom f
diags.Append(expander.nestedObjectToSlice(ctx, vFrom, tTo, tElem, vTo)...)
return diags
}

case reflect.Interface:
//
// types.List(OfObject) -> []interface.
//
// Smithy union type handling not yet implemented. Silently skip.
return diags
}

case reflect.Interface:
//
// types.List(OfObject) -> interface.
//
// Smithy union type handling not yet implemented. Silently skip.
return diags
}

diags.AddError("Incompatible types", fmt.Sprintf("nestedObject[%s] cannot be expanded to %s", vFrom.Type(ctx).(attr.TypeWithElementType).ElementType(), vTo.Kind()))
diags.AddError("Incompatible types", fmt.Sprintf("nestedObjectCollection[%s] cannot be expanded to %s", vFrom.Type(ctx).(attr.TypeWithElementType).ElementType(), vTo.Kind()))
return diags
}

Expand Down
8 changes: 8 additions & 0 deletions internal/framework/flex/auto_flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (flattener autoFlattener) convert(ctx context.Context, vFrom, vTo reflect.V
case reflect.Struct:
diags.Append(flattener.struct_(ctx, vFrom, false, tTo, vTo)...)
return diags

case reflect.Interface:
// Smithy union type handling not yet implemented. Silently skip.
return diags
}

tflog.Info(ctx, "AutoFlex Flatten; incompatible types", map[string]interface{}{
Expand Down Expand Up @@ -494,6 +498,10 @@ func (flattener autoFlattener) slice(ctx context.Context, vFrom reflect.Value, t
diags.Append(flattener.sliceOfStructNestedObjectCollection(ctx, vFrom, tTo, vTo)...)
return diags
}

case reflect.Interface:
// Smithy union type handling not yet implemented. Silently skip.
return diags
}

tflog.Info(ctx, "AutoFlex Flatten; incompatible types", map[string]interface{}{
Expand Down
170 changes: 170 additions & 0 deletions internal/framework/types/once_a_week_window.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"context"
"fmt"
"strings"

"github.com/YakDriver/regexache"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/attr/xattr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

var (
_ xattr.TypeWithValidate = (*onceAWeekWindowType)(nil)
_ basetypes.StringTypable = (*onceAWeekWindowType)(nil)
_ basetypes.StringValuable = (*OnceAWeekWindow)(nil)
_ basetypes.StringValuableWithSemanticEquals = (*OnceAWeekWindow)(nil)
)

type onceAWeekWindowType struct {
basetypes.StringType
}

var (
OnceAWeekWindowType = onceAWeekWindowType{}
)

func (t onceAWeekWindowType) Equal(o attr.Type) bool {
other, ok := o.(onceAWeekWindowType)
if !ok {
return false
}

return t.StringType.Equal(other.StringType)
}

func (onceAWeekWindowType) String() string {
return "OnceAWeekWindowType"
}

func (t onceAWeekWindowType) ValueFromString(_ context.Context, in types.String) (basetypes.StringValuable, diag.Diagnostics) {
var diags diag.Diagnostics

if in.IsNull() {
return OnceAWeekWindowNull(), diags
}
if in.IsUnknown() {
return OnceAWeekWindowUnknown(), diags
}

return OnceAWeekWindowValue(in.ValueString()), diags
}

func (t onceAWeekWindowType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
attrValue, err := t.StringType.ValueFromTerraform(ctx, in)
if err != nil {
return nil, err
}

stringValue, ok := attrValue.(basetypes.StringValue)
if !ok {
return nil, fmt.Errorf("unexpected value type of %T", attrValue)
}

stringValuable, diags := t.ValueFromString(ctx, stringValue)
if diags.HasError() {
return nil, fmt.Errorf("unexpected error converting StringValue to StringValuable: %v", diags)
}

return stringValuable, nil
}

func (onceAWeekWindowType) ValueType(context.Context) attr.Value {
return OnceAWeekWindow{}
}

func (t onceAWeekWindowType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics {
var diags diag.Diagnostics

if !in.IsKnown() || in.IsNull() {
return diags
}

var value string
err := in.As(&value)
if err != nil {
diags.AddAttributeError(
path,
"OnceAWeekWindowType Validation Error",
ProviderErrorDetailPrefix+fmt.Sprintf("Cannot convert value to string: %s", err),
)
return diags
}

// Valid time format is "ddd:hh24:mi".
validTimeFormat := "(sun|mon|tue|wed|thu|fri|sat):([0-1][0-9]|2[0-3]):([0-5][0-9])"
validTimeFormatConsolidated := "^(" + validTimeFormat + "-" + validTimeFormat + "|)$"

if v := strings.ToLower(value); !regexache.MustCompile(validTimeFormatConsolidated).MatchString(v) {
diags.AddAttributeError(
path,
"OnceAWeekWindowType Validation Error",
fmt.Sprintf("Value %q must satisfy the format of \"ddd:hh24:mi-ddd:hh24:mi\".", value),
)
return diags
}

return diags
}

type OnceAWeekWindow struct {
basetypes.StringValue
}

func OnceAWeekWindowNull() OnceAWeekWindow {
return OnceAWeekWindow{StringValue: basetypes.NewStringNull()}
}

func OnceAWeekWindowUnknown() OnceAWeekWindow {
return OnceAWeekWindow{StringValue: basetypes.NewStringUnknown()}
}

func OnceAWeekWindowValue(value string) OnceAWeekWindow {
return OnceAWeekWindow{StringValue: basetypes.NewStringValue(value)}
}

func (v OnceAWeekWindow) Equal(o attr.Value) bool {
other, ok := o.(OnceAWeekWindow)
if !ok {
return false
}

return v.StringValue.Equal(other.StringValue)
}

func (OnceAWeekWindow) Type(context.Context) attr.Type {
return OnceAWeekWindowType
}

func (v OnceAWeekWindow) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics) {
var diags diag.Diagnostics

newValue, ok := newValuable.(OnceAWeekWindow)
if !ok {
return false, diags
}

old, d := v.ToStringValue(ctx)
diags.Append(d...)
if diags.HasError() {
return false, diags
}

new, d := newValue.ToStringValue(ctx)
diags.Append(d...)
if diags.HasError() {
return false, diags
}

// Case insensitive comparison.
return strings.EqualFold(old.ValueString(), new.ValueString()), diags
}
114 changes: 114 additions & 0 deletions internal/framework/types/once_a_week_window_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types_test

import (
"context"
"testing"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-go/tftypes"
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
)

func TestOnceAWeekWindowTypeValidate(t *testing.T) {
t.Parallel()

type testCase struct {
val tftypes.Value
expectError bool
}
tests := map[string]testCase{
"not a string": {
val: tftypes.NewValue(tftypes.Bool, true),
expectError: true,
},
"unknown string": {
val: tftypes.NewValue(tftypes.String, tftypes.UnknownValue),
},
"null string": {
val: tftypes.NewValue(tftypes.String, nil),
},
"valid string lowercase": {
val: tftypes.NewValue(tftypes.String, "thu:07:44-thu:09:44"),
},
"valid string uppercase": {
val: tftypes.NewValue(tftypes.String, "THU:07:44-THU:09:44"),
},
"invalid string": {
val: tftypes.NewValue(tftypes.String, "thu:25:44-zat:09:88"),
expectError: true,
},
}

for name, test := range tests {
name, test := name, test
t.Run(name, func(t *testing.T) {
t.Parallel()

ctx := context.Background()

diags := fwtypes.OnceAWeekWindowType.Validate(ctx, test.val, path.Root("test"))

if !diags.HasError() && test.expectError {
t.Fatal("expected error, got no error")
}

if diags.HasError() && !test.expectError {
t.Fatalf("got unexpected error: %#v", diags)
}
})
}
}

func TestOnceAWeekWindowStringSemanticEquals(t *testing.T) {
t.Parallel()

type testCase struct {
val1, val2 fwtypes.OnceAWeekWindow
equals bool
}
tests := map[string]testCase{
"both lowercase, equal": {
val1: fwtypes.OnceAWeekWindowValue("thu:07:44-thu:09:44"),
val2: fwtypes.OnceAWeekWindowValue("thu:07:44-thu:09:44"),
equals: true,
},
"both uppercase, equal": {
val1: fwtypes.OnceAWeekWindowValue("THU:07:44-THU:09:44"),
val2: fwtypes.OnceAWeekWindowValue("THU:07:44-THU:09:44"),
equals: true,
},
"first uppercase, second lowercase, equal": {
val1: fwtypes.OnceAWeekWindowValue("THU:07:44-THU:09:44"),
val2: fwtypes.OnceAWeekWindowValue("thu:07:44-thu:09:44"),
equals: true,
},
"first lowercase, second uppercase, equal": {
val1: fwtypes.OnceAWeekWindowValue("thu:07:44-thu:09:44"),
val2: fwtypes.OnceAWeekWindowValue("THU:07:44-THU:09:44"),
equals: true,
},
"not equal": {
val1: fwtypes.OnceAWeekWindowValue("thu:07:44-thu:09:44"),
val2: fwtypes.OnceAWeekWindowValue("thu:07:44-fri:11:09"),
equals: false,
},
}

for name, test := range tests {
name, test := name, test
t.Run(name, func(t *testing.T) {
t.Parallel()

ctx := context.Background()

equals, _ := test.val1.StringSemanticEquals(ctx, test.val2)

if got, want := equals, test.equals; got != want {
t.Errorf("StringSemanticEquals(%q, %q) = %v, want %v", test.val1, test.val2, got, want)
}
})
}
}
Loading
Loading