-
Notifications
You must be signed in to change notification settings - Fork 0
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
859115f
commit 7d2fa04
Showing
7 changed files
with
91 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Return the remainder of 4 / 2 | ||
data "stdlib_mod" "zero" { | ||
dividend = 4 | ||
divisor = 2 | ||
} | ||
# => 0 | ||
|
||
# Return the remainder of 5 / 3 | ||
data "stdlib_mod" "integer" { | ||
dividend = 5 | ||
divisor = 3 | ||
} | ||
# => 2 | ||
|
||
# Return the remainder of 10 / 3.5 | ||
data "stdlib_mod" "decimal" { | ||
dividend = 10 | ||
divisor = 4.75 | ||
} | ||
# => 0.5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package numberfunc_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
|
||
"github.com/mschuchard/terraform-provider-stdlib/stdlib" | ||
) | ||
|
||
func TestAccMod(test *testing.T) { | ||
// invoke test | ||
resource.ParallelTest(test, resource.TestCase{ | ||
ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// test basic 0 remainder | ||
{ | ||
Config: `data "stdlib_mod" "test" { | ||
dividend = 4 | ||
divisor = 2 | ||
}`, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
// verify input params are stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "dividend", "4"), | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "divisor", "2"), | ||
// verify remainder result is stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "result", "0"), | ||
// verify id stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "id", "2"), | ||
), | ||
}, | ||
// test basic integer remainder | ||
{ | ||
Config: `data "stdlib_mod" "test" { | ||
dividend = 5 | ||
divisor = 3 | ||
}`, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
// verify input params are stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "dividend", "5"), | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "divisor", "3"), | ||
// verify remainder result is stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "result", "2"), | ||
// verify id stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "id", "3"), | ||
), | ||
}, | ||
// test basic float remainder | ||
{ | ||
Config: `data "stdlib_mod" "test" { | ||
dividend = 10 | ||
divisor = 4.75 | ||
}`, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
// verify input params are stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "dividend", "10"), | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "divisor", "4.75"), | ||
// verify remainder result is stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "result", "0.5"), | ||
// verify id stored correctly | ||
resource.TestCheckResourceAttr("data.stdlib_mod.test", "id", "4.75"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
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