-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e882eb
commit feea178
Showing
9 changed files
with
223 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/BESTSELLER/terraform-provider-servicenow-data/internal/provider" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var testAccProviders map[string]*schema.Provider | ||
var testAccProvider *schema.Provider | ||
|
||
func init() { | ||
testAccProvider = provider.ServiceNowDataProvider() | ||
testAccProviders = map[string]*schema.Provider{ | ||
"sericenow-data": testAccProvider, | ||
} | ||
} | ||
|
||
func TestProvider(t *testing.T) { | ||
if err := Provider().InternalValidate(); err != nil { | ||
t.Fatalf("err: %s", err) | ||
} | ||
} | ||
|
||
func TestProvider_impl(t *testing.T) { | ||
var _ *schema.Provider = Provider() | ||
} | ||
func testAccPreCheck(t *testing.T) { | ||
if err := os.Getenv("SN_API_URL"); err == "" { | ||
t.Fatal("SN_API_URL must be set for acceptance tests") | ||
} | ||
if err := os.Getenv("SN_API_USER"); err == "" { | ||
t.Fatal("SN_API_USER must be set for acceptance tests") | ||
} | ||
if err := os.Getenv("SN_API_PASS"); err == "" { | ||
t.Fatal("SN_API_PASS must be set for acceptance tests") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/BESTSELLER/terraform-provider-servicenow-data/internal/client" | ||
"github.com/BESTSELLER/terraform-provider-servicenow-data/internal/datasource" | ||
resource2 "github.com/BESTSELLER/terraform-provider-servicenow-data/internal/resource" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAccRowBasic(t *testing.T) { | ||
tableId := "x_beas_team_engi_0_lasse" | ||
team := "engineering-services" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckRowDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckRowBasic(tableId, team), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckRowExists("servicenow-data_table_row.eng-services-test"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckRowDestroy(s *terraform.State) error { | ||
c := testAccProvider.Meta().(*client.Client) | ||
|
||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != resource2.TableRowResourceName { | ||
continue | ||
} | ||
|
||
tableID, rowID, err := datasource.ExtractIDs(rs.Primary.ID) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
err = c.DeleteTableRow(tableID, rowID) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func testAccCheckRowBasic(tableId, team string) string { | ||
return fmt.Sprintf(` | ||
resource "servicenow-data_table_row" "eng-services-test" { | ||
table_id = "%s" | ||
row_data = { | ||
"team": "%s", | ||
} | ||
} | ||
`, tableId, team) | ||
} | ||
|
||
func testAccCheckRowExists(n string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
|
||
if !ok { | ||
return fmt.Errorf("Not found: %s", n) | ||
} | ||
|
||
if rs.Primary.ID == "" { | ||
return fmt.Errorf("No OrderID set") | ||
} | ||
|
||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"version": 1, | ||
"metadata": { | ||
"protocol_versions": [ | ||
"5.0" | ||
] | ||
} | ||
} |