From 54e689d62d96a83628a63d019ebdfebfb2078ab7 Mon Sep 17 00:00:00 2001 From: jonaustin09 Date: Thu, 18 May 2023 14:32:21 +0400 Subject: [PATCH] feat: create empty unit tests --- s3api/controllers/base_test.go | 283 +++++++++++++++++++++++++++++++++ s3api/router_test.go | 27 ++++ s3api/server_test.go | 54 +++++++ 3 files changed, 364 insertions(+) create mode 100644 s3api/controllers/base_test.go create mode 100644 s3api/router_test.go create mode 100644 s3api/server_test.go diff --git a/s3api/controllers/base_test.go b/s3api/controllers/base_test.go new file mode 100644 index 0000000..2cda682 --- /dev/null +++ b/s3api/controllers/base_test.go @@ -0,0 +1,283 @@ +package controllers + +import ( + "reflect" + "testing" + + "github.com/gofiber/fiber/v2" + "github.com/versity/scoutgw/backend" + "github.com/versity/scoutgw/s3err" +) + +func TestNew(t *testing.T) { + type args struct { + be backend.Backend + } + tests := []struct { + name string + args args + want S3ApiController + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := New(tt.args.be); !reflect.DeepEqual(got, tt.want) { + t.Errorf("New() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestS3ApiController_ListBuckets(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.ListBuckets(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.ListBuckets() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_GetActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.GetActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.GetActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_ListActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.ListActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.ListActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_PutBucketActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.PutBucketActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.PutBucketActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_PutActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.PutActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.PutActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_DeleteBucket(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.DeleteBucket(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.DeleteBucket() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_DeleteObjects(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.DeleteObjects(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.DeleteObjects() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_DeleteActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.DeleteActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.DeleteActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_HeadBucket(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.HeadBucket(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.HeadBucket() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_HeadObject(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.HeadObject(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.HeadObject() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestS3ApiController_CreateActions(t *testing.T) { + type args struct { + ctx *fiber.Ctx + } + tests := []struct { + name string + c S3ApiController + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.c.CreateActions(tt.args.ctx); (err != nil) != tt.wantErr { + t.Errorf("S3ApiController.CreateActions() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func Test_responce(t *testing.T) { + type args struct { + ctx *fiber.Ctx + resp any + code s3err.ErrorCode + } + tests := []struct { + name string + args args + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := responce(tt.args.ctx, tt.args.resp, tt.args.code); (err != nil) != tt.wantErr { + t.Errorf("responce() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} diff --git a/s3api/router_test.go b/s3api/router_test.go new file mode 100644 index 0000000..4a1e194 --- /dev/null +++ b/s3api/router_test.go @@ -0,0 +1,27 @@ +package s3api + +import ( + "testing" + + "github.com/gofiber/fiber/v2" + "github.com/versity/scoutgw/backend" +) + +func TestS3ApiRouter_Init(t *testing.T) { + type args struct { + app *fiber.App + be backend.Backend + } + tests := []struct { + name string + sa *S3ApiRouter + args args + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.sa.Init(tt.args.app, tt.args.be) + }) + } +} diff --git a/s3api/server_test.go b/s3api/server_test.go new file mode 100644 index 0000000..8e2e963 --- /dev/null +++ b/s3api/server_test.go @@ -0,0 +1,54 @@ +package s3api + +import ( + "reflect" + "testing" + + "github.com/gofiber/fiber/v2" + "github.com/versity/scoutgw/backend" +) + +func TestNew(t *testing.T) { + type args struct { + app *fiber.App + be backend.Backend + port string + } + tests := []struct { + name string + args args + wantS3ApiServer *S3ApiServer + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotS3ApiServer, err := New(tt.args.app, tt.args.be, tt.args.port) + if (err != nil) != tt.wantErr { + t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(gotS3ApiServer, tt.wantS3ApiServer) { + t.Errorf("New() = %v, want %v", gotS3ApiServer, tt.wantS3ApiServer) + } + }) + } +} + +func TestS3ApiServer_Serve(t *testing.T) { + tests := []struct { + name string + sa *S3ApiServer + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if err := tt.sa.Serve(); (err != nil) != tt.wantErr { + t.Errorf("S3ApiServer.Serve() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +}