From b08b08d6a0d65ee3f3d8a6c2d2276b89cfe81092 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 21 Nov 2024 12:59:30 +0300 Subject: [PATCH] [#6] Fix test struct tag naming Signed-off-by: Denis Kirillov --- cmd/parser/modules/compatibility.go | 2 + go.mod | 3 + internal/s3/resources/tests-struct.json | 99 +++++++++++++------------ internal/s3/structure_test.go | 17 +++++ 4 files changed, 72 insertions(+), 49 deletions(-) create mode 100644 internal/s3/structure_test.go diff --git a/cmd/parser/modules/compatibility.go b/cmd/parser/modules/compatibility.go index 3fe3bc0..e404a3b 100644 --- a/cmd/parser/modules/compatibility.go +++ b/cmd/parser/modules/compatibility.go @@ -161,6 +161,8 @@ func formTestResult(group s3.Group, testsMap map[string]bool) TestResult { color = templates.BlueColor } else if strings.Contains(group.Comment, "Not applicable") { color = templates.BlackColor + } else if ln == 0 && !group.Skip { + color = templates.GreenColor } if color == "" { diff --git a/go.mod b/go.mod index 7f810d0..9f07aab 100644 --- a/go.mod +++ b/go.mod @@ -5,15 +5,18 @@ go 1.20 require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 + github.com/stretchr/testify v1.8.3 ) require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/internal/s3/resources/tests-struct.json b/internal/s3/resources/tests-struct.json index 660cd0b..db1eec2 100644 --- a/internal/s3/resources/tests-struct.json +++ b/internal/s3/resources/tests-struct.json @@ -129,7 +129,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketCors", @@ -149,21 +149,21 @@ "test_delete_bucket_encryption_kms" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketIntelligentTieringConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketInventoryConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketLifecycle", @@ -180,14 +180,14 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketOwnershipControls", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketPolicy", @@ -204,7 +204,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteBucketTagging", @@ -221,7 +221,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "DeleteObject", @@ -269,7 +269,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketAccelerateConfiguration", @@ -293,7 +293,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketCors", @@ -313,21 +313,21 @@ "test_get_bucket_encryption_kms" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketIntelligentTieringConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketInventoryConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketLifecycle", @@ -363,35 +363,35 @@ "test_logging_toggle" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketMetricsConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketNotification", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketNotificationConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketOwnershipControls", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketPolicy", @@ -408,14 +408,14 @@ "tag": "API", "tests": [], "skip": false, - "comment": "Party supported" + "comment": "Party supported, but there are not compatibility tests" }, { "name": "GetBucketReplication", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetBucketRequestPayment", @@ -449,7 +449,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "GetObject", @@ -494,7 +494,7 @@ "tag": "API", "tests": [], "skip": false, - "comment": "" + "comment": "Supported, but there are not compatibility tests" }, { "name": "GetObjectLegalHold", @@ -552,7 +552,7 @@ "test_get_default_public_block" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "HeadBucket", @@ -581,28 +581,28 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "ListBucketIntelligentTieringConfigurations", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "ListBucketInventoryConfigurations", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "ListBucketMetricsConfigurations", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "ListBuckets", @@ -739,7 +739,7 @@ "tag": "API", "tests": [], "skip": false, - "comment": "" + "comment": "Supported, but there are not compatibility tests" }, { "name": "PutBucketAccelerateConfiguration", @@ -752,7 +752,7 @@ "name": "PutBucketAcl", "tag": "API", "tests": [], - "include":[ + "include": [ "BucketACL" ], "skip": false, @@ -763,7 +763,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketCors", @@ -795,21 +795,21 @@ "test_sse_kms_default_upload_8mb" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketIntelligentTieringConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketInventoryConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketLifecycle", @@ -836,35 +836,35 @@ "test_logging_toggle" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketMetricsConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketNotification", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketNotificationConfiguration", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketOwnershipControls", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketPolicy", @@ -881,7 +881,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutBucketRequestPayment", @@ -915,7 +915,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "PutObject", @@ -1005,14 +1005,14 @@ "test_ignore_public_acls" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "RestoreObject", "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "SelectObjectContent", @@ -1054,7 +1054,7 @@ "test_output_serial_expressions" ], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "UploadPart", @@ -1100,7 +1100,7 @@ "tag": "API", "tests": [], "skip": true, - "comment": "Not supported yet, but will be in future" + "comment": "Not supported" }, { "name": "BucketPolicy", @@ -1195,7 +1195,7 @@ }, { "name": "BucketACL", - "tags": "Features", + "tag": "Features", "tests": [ "test_bucket_put_bad_canned_acl", "test_bucket_list_objects_anonymous", @@ -1210,7 +1210,7 @@ }, { "name": "BucketVersioning", - "tags": "Features", + "tag": "Features", "tests": [ "test_object_lock_put_obj_lock", "test_multipart_copy_versioned", @@ -1240,7 +1240,7 @@ }, { "name": "MultipartUpload", - "tags": "Features", + "tag": "Features", "tests": [ "test_multipart_upload" ], @@ -1249,13 +1249,14 @@ "CompleteMultipartUpload", "ListMultipartUploads", "UploadPart", - "UploadPartCopy" + "UploadPartCopy", + "ListParts" ], "skip": false, "comment": "" }, { - "name": "encryption", + "name": "Encryption", "tag": "Features", "tests": [ "test_encrypted_transfer_1b", diff --git a/internal/s3/structure_test.go b/internal/s3/structure_test.go new file mode 100644 index 0000000..e7a8fe4 --- /dev/null +++ b/internal/s3/structure_test.go @@ -0,0 +1,17 @@ +package s3 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestStructParsing(t *testing.T) { + structure, err := ParseTestsStruct() + require.NoError(t, err) + + for _, group := range structure.Groups { + require.NotEmptyf(t, group.Tag, "group tag must not be empty: %v", group) + require.NotEmptyf(t, group.Name, "group name must not be empty: %v", group) + } +}