@@ -2,6 +2,7 @@ package file_test
22
33import (
44 "fmt"
5+ "regexp"
56 "testing"
67
78 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -18,6 +19,7 @@ func TestAccFileSystem_Basic(t *testing.T) {
1819
1920 fileSystemName := "TestAccFileSystem_Basic"
2021 fileSystemNameUpdated := "TestAccFileSystem_BasicUpdate"
22+ size := int64 (100_000_000_000 )
2123
2224 resource .ParallelTest (t , resource.TestCase {
2325 PreCheck : func () { acctest .PreCheck (t ) },
@@ -26,37 +28,58 @@ func TestAccFileSystem_Basic(t *testing.T) {
2628 Steps : []resource.TestStep {
2729 {
2830 Config : fmt .Sprintf (`
29- resource "scaleway_file_filesysten " "fs" {
31+ resource "scaleway_file_filesystem " "fs" {
3032 name = "%s"
31- size = 10000000000
33+ size = %d
3234 }
33-
34-
35- ` , fileSystemName ),
35+ ` , fileSystemName , size ),
3636 Check : resource .ComposeTestCheckFunc (
3737 testAccCheckFileSystemExists (tt , "scaleway_file_filesystem.fs" ),
3838 resource .TestCheckResourceAttr ("scaleway_file_filesystem.fs" , "name" , fileSystemName ),
39- resource .TestCheckResourceAttr ("scaleway_file_filesystem.fs" , "size" , "10000000000" ),
39+ resource .TestCheckResourceAttr ("scaleway_file_filesystem.fs" , "size" , fmt . Sprintf ( "%d" , size ) ),
4040 ),
4141 },
4242 {
4343 Config : fmt .Sprintf (`
44- resource "scaleway_file_filesysten " "fs" {
44+ resource "scaleway_file_filesystem " "fs" {
4545 name = "%s"
46- size = 10000000000
46+ size = %d
4747 }
48-
49-
50- ` , fileSystemNameUpdated ),
48+ ` , fileSystemNameUpdated , size ),
5149 Check : resource .ComposeTestCheckFunc (
5250 testAccCheckFileSystemExists (tt , "scaleway_file_filesystem.fs" ),
53- resource .TestCheckResourceAttr ("scaleway_file_filesystem.fs" , "size" , "10000000000" ),
51+ resource .TestCheckResourceAttr ("scaleway_file_filesystem.fs" , "size" , fmt . Sprintf ( "%d" , size ) ),
5452 ),
5553 },
5654 },
5755 })
5856}
5957
58+ func TestAccFileSystem_SizeTooSmallFails (t * testing.T ) {
59+ tt := acctest .NewTestTools (t )
60+ defer tt .Cleanup ()
61+
62+ fileSystemName := "TestAccFileSystem_Basic"
63+ size := int64 (10_000_000_000 )
64+
65+ resource .ParallelTest (t , resource.TestCase {
66+ PreCheck : func () { acctest .PreCheck (t ) },
67+ ProviderFactories : tt .ProviderFactories ,
68+ CheckDestroy : filetestfuncs .CheckFileDestroy (tt ),
69+ Steps : []resource.TestStep {
70+ {
71+ Config : fmt .Sprintf (`
72+ resource "scaleway_file_filesystem" "fs" {
73+ name = "%s"
74+ size = %d
75+ }
76+ ` , fileSystemName , size ),
77+ ExpectError : regexp .MustCompile ("size does not respect constraint, size must be greater or equal to 100000000000" ),
78+ },
79+ },
80+ })
81+ }
82+
6083func testAccCheckFileSystemExists (tt * acctest.TestTools , n string ) resource.TestCheckFunc {
6184 return func (s * terraform.State ) error {
6285 rs , ok := s .RootModule ().Resources [n ]
0 commit comments