@@ -4,12 +4,14 @@ import (
44 "crypto/rand"
55 "crypto/rsa"
66 "fmt"
7- "regexp"
87 "strings"
98 "testing"
109
1110 "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1211 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
12+ "github.com/hashicorp/terraform-plugin-testing/knownvalue"
13+ "github.com/hashicorp/terraform-plugin-testing/statecheck"
14+ "github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
1315 "golang.org/x/crypto/ssh"
1416)
1517
@@ -26,18 +28,16 @@ func TestAccGithubUserSshSigningKey(t *testing.T) {
2628 }
2729 ` , name , testKey )
2830
29- check := resource .ComposeTestCheckFunc (
30- resource .TestMatchResourceAttr ("github_user_ssh_signing_key.test" , "title" , regexp .MustCompile (randomID )),
31- resource .TestMatchResourceAttr ("github_user_ssh_signing_key.test" , "key" , regexp .MustCompile ("^ssh-rsa " )),
32- )
33-
3431 resource .Test (t , resource.TestCase {
3532 PreCheck : func () { skipUnauthenticated (t ) },
3633 ProviderFactories : providerFactories ,
3734 Steps : []resource.TestStep {
3835 {
3936 Config : config ,
40- Check : check ,
37+ ConfigStateChecks : []statecheck.StateCheck {
38+ statecheck .ExpectKnownValue ("github_user_ssh_signing_key.test" , tfjsonpath .New ("title" ), knownvalue .StringExact (name )),
39+ statecheck .ExpectKnownValue ("github_user_ssh_signing_key.test" , tfjsonpath .New ("key" ), knownvalue .StringExact (testKey )),
40+ },
4141 },
4242 },
4343 })
@@ -55,18 +55,16 @@ func TestAccGithubUserSshSigningKey(t *testing.T) {
5555 }
5656 ` , name , testKey )
5757
58- check := resource .ComposeTestCheckFunc (
59- resource .TestCheckResourceAttrSet ("github_user_ssh_signing_key.test" , "title" ),
60- resource .TestCheckResourceAttrSet ("github_user_ssh_signing_key.test" , "key" ),
61- )
62-
6358 resource .Test (t , resource.TestCase {
6459 PreCheck : func () { skipUnauthenticated (t ) },
6560 ProviderFactories : providerFactories ,
6661 Steps : []resource.TestStep {
6762 {
6863 Config : config ,
69- Check : check ,
64+ ConfigStateChecks : []statecheck.StateCheck {
65+ statecheck .ExpectKnownValue ("github_user_ssh_signing_key.test" , tfjsonpath .New ("title" ), knownvalue .StringExact (name )),
66+ statecheck .ExpectKnownValue ("github_user_ssh_signing_key.test" , tfjsonpath .New ("key" ), knownvalue .StringExact (testKey )),
67+ },
7068 },
7169 {
7270 ResourceName : "github_user_ssh_signing_key.test" ,
0 commit comments