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

provider/aws: Added a set of tests for the DBParamGroup Name #3446

Merged
merged 5 commits into from
Oct 8, 2015

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Oct 8, 2015

make testacc TEST=./builtin/providers/aws TESTARGS='-run=DBParameterGroup' 2>~/tf.log
go generate ./...
TF_ACC=1 go test ./builtin/providers/aws -v -run=DBParameterGroup -timeout 90m
=== RUN   TestAccAWSDBParameterGroup_basic
--- PASS: TestAccAWSDBParameterGroup_basic (6.04s)
=== RUN   TestAccAWSDBParameterGroupOnly
--- PASS: TestAccAWSDBParameterGroupOnly (3.76s)
=== RUN   TestResourceAWSDBParameterGroupName_uppercaseCharacter
--- PASS: TestResourceAWSDBParameterGroupName_uppercaseCharacter (0.00s)
=== RUN   TestResourceAWSDBParameterGroupName_specialCharacters
--- PASS: TestResourceAWSDBParameterGroupName_specialCharacters (0.00s)
=== RUN   TestResourceAWSDBParameterGroupName_firstCharacterNumber
--- PASS: TestResourceAWSDBParameterGroupName_firstCharacterNumber (0.00s)
=== RUN   TestResourceAWSDBParameterGroupName_doubleHyphen
--- PASS: TestResourceAWSDBParameterGroupName_doubleHyphen (0.00s)
=== RUN   TestResourceAWSDBParameterGroupName_trailingHyphen
--- PASS: TestResourceAWSDBParameterGroupName_trailingHyphen (0.00s)
=== RUN   TestResourceAWSDBParameterGroupName_tooManyCharacters
--- PASS: TestResourceAWSDBParameterGroupName_tooManyCharacters (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    9.815s

@radeksimko as requested in #3279

@stack72
Copy link
Contributor Author

stack72 commented Oct 8, 2015

@radeksimko I added a small func that creates a RandomString of fixed length. This may be useful for other tests. If you think that should be moved to a different location then let me know

@stack72 stack72 changed the title Added a set of tests for the AWS DBParamGroup Name provider/aws: Added a set of tests for the DBParamGroup Name Oct 8, 2015
if len(errors) != 1 {
t.Fatalf("Expected the DB Parameter Group Name to trigger a validation error")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of tests! Since they're all testing the same method with different inputs, can we re-write this to be a table test?

func TestResourceAWSDBParameterGroupName_validation(t *testing.T) {
    cases := []struct {
        Value    string
        ErrCount int
    }{
        {
            Value:    "tEsting123",
            ErrCount: 1,
        },
        {
            Value:    "testing123!",
            ErrCount: 1,
        },
               # [.. so on ..]
    }

    for _, tc := range cases {
        _, errors := validateDbParamGroupName(tc.Value, "SampleKey")
        if len(errors) != ErrCount {
            t.Fatalf("Expected the DB Parameter Group Name to trigger a validation error")
        }
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooohhh! I didn't realise this. Updating right now

Thanks @catsby

@catsby
Copy link
Contributor

catsby commented Oct 8, 2015

Small nitpicks but otherwise 👍

@catsby catsby added enhancement waiting-response An issue/pull request is waiting for a response from the community provider/aws labels Oct 8, 2015
@stack72
Copy link
Contributor Author

stack72 commented Oct 8, 2015

Thanks @catsby! This is now taken care of :) (This is a really useful Go tip for me!)

make testacc TEST=./builtin/providers/aws TESTARGS='-run=DBParameterGroup' 2>~/tf.log
go generate ./...
TF_ACC=1 go test ./builtin/providers/aws -v -run=DBParameterGroup -timeout 90m
=== RUN   TestAccAWSDBParameterGroup_basic
--- PASS: TestAccAWSDBParameterGroup_basic (5.58s)
=== RUN   TestAccAWSDBParameterGroupOnly
--- PASS: TestAccAWSDBParameterGroupOnly (2.84s)
=== RUN   TestResourceAWSDBParameterGroupName_validation
--- PASS: TestResourceAWSDBParameterGroupName_validation (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    8.472s

@stack72
Copy link
Contributor Author

stack72 commented Oct 8, 2015

@catsby this build is working on my local machine but yet fails on travis. Any reason why?

…is an edge case that this could actually trigger a failure due to not allowing to start with a number
@stack72
Copy link
Contributor Author

stack72 commented Oct 8, 2015

ok false alarm - this was due to an edgecase in my tests where the randomString generator could have given me a string starting with a number and thus failed the test

@catsby
Copy link
Contributor

catsby commented Oct 8, 2015

ok false alarm - this was due to an edgecase in my tests where the randomString generator could have given me a string starting with a number and thus failed the test

Glad you figured it out, I was confused as well since it was passing for me. resource has a uniqueID method, maybe you can borrow code from that?

Either way, I assume you're patching? Thanks!

@stack72
Copy link
Contributor Author

stack72 commented Oct 8, 2015

@catsby all patched and ready for merge :)

@catsby
Copy link
Contributor

catsby commented Oct 8, 2015

Thanks!

catsby added a commit that referenced this pull request Oct 8, 2015
provider/aws: Added a set of tests for the DBParamGroup Name
@catsby catsby merged commit 877f9f8 into hashicorp:master Oct 8, 2015
@ghost
Copy link

ghost commented Apr 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants