Skip to content

Commit 4e63e19

Browse files
committed
fix date issue and register cassettes
1 parent f56f23c commit 4e63e19

File tree

5 files changed

+935
-14
lines changed

5 files changed

+935
-14
lines changed

internal/services/file/filesystem.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package file
22

33
import (
44
"context"
5+
"time"
56

67
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
78
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -129,8 +130,8 @@ func ResourceFileSystemRead(ctx context.Context, d *schema.ResourceData, m inter
129130
_ = d.Set("status", fileSystem.Status)
130131
_ = d.Set("size", fileSystem.Size)
131132
_ = d.Set("tags", fileSystem.Tags)
132-
_ = d.Set("created_at", fileSystem.CreatedAt)
133-
_ = d.Set("updated_at", fileSystem.UpdatedAt)
133+
_ = d.Set("created_at", fileSystem.CreatedAt.Format(time.RFC3339))
134+
_ = d.Set("updated_at", fileSystem.UpdatedAt.Format(time.RFC3339))
134135
_ = d.Set("number_of_attachments", fileSystem.NumberOfAttachments)
135136

136137
return nil

internal/services/file/filesystem_test.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package file_test
22

33
import (
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+
6083
func 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

Comments
 (0)