github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/cmd/test/command/cmd_gen_function_test.go (about) 1 package main 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/easysoft/zendata/cmd/test/consts" 8 "github.com/easysoft/zendata/cmd/test/gen" 9 testHelper "github.com/easysoft/zendata/cmd/test/helper" 10 "github.com/ozontech/allure-go/pkg/framework/provider" 11 "github.com/ozontech/allure-go/pkg/framework/suite" 12 ) 13 14 func TestGenerateFunctionCmd(t *testing.T) { 15 suite.RunSuite(t, new(GenerateFunctionCmdSuite)) 16 } 17 18 type GenerateFunctionCmdSuite struct { 19 suite.Suite 20 } 21 22 func (s *GenerateFunctionCmdSuite) BeforeAll(t provider.T) { 23 testHelper.BeforeAll() 24 t.AddSubSuite("GenerateFunctionCmd") 25 } 26 func (s *GenerateFunctionCmdSuite) BeforeEach(t provider.T) { 27 testHelper.PreCase() 28 t.AddSubSuite("GenerateFunctionCmd") 29 } 30 func (s *GenerateFunctionCmdSuite) AfterEach(t provider.T) { 31 testHelper.PostCase() 32 } 33 34 func (s *GenerateFunctionCmdSuite) TestGenerateFuncMd5(t provider.T) { 35 t.ID("0") 36 37 out := gen.New(). 38 SetTotal(5). 39 SetConfigs([]string{consts.CommandTestFile}). 40 SetFields("f51"). 41 Gen() 42 43 arr := strings.Split(out, "\t\n") 44 45 t.Require().Equal(len(arr[0]), 32, "check generated data") 46 } 47 48 func (s *GenerateFunctionCmdSuite) TestGenerateFuncSha1(t provider.T) { 49 t.ID("0") 50 51 out := gen.New(). 52 SetTotal(5). 53 SetConfigs([]string{consts.CommandTestFile}). 54 SetFields("f52"). 55 Gen() 56 57 arr := strings.Split(out, "\t\n") 58 59 t.Require().Equal(len(arr[0]), 40, "check generated data") 60 } 61 62 func (s *GenerateFunctionCmdSuite) TestGenerateFuncBase64(t provider.T) { 63 t.ID("0") 64 65 out := gen.New(). 66 SetTotal(5). 67 SetConfigs([]string{consts.CommandTestFile}). 68 SetFields("f53"). 69 Gen() 70 71 arr := strings.Split(out, "\t\n") 72 73 t.Require().Equal(len(arr[0]), 36, "check generated data") 74 } 75 76 func (s *GenerateFunctionCmdSuite) TestGenerateFuncUrlencode(t provider.T) { 77 t.ID("0") 78 79 out := gen.New(). 80 SetTotal(5). 81 SetConfigs([]string{consts.CommandTestFile}). 82 SetFields("f54"). 83 Gen() 84 85 arr := strings.Split(out, "\t\n") 86 87 t.Require().Equal(len(arr[0]), 39, "check generated data") 88 }