github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/cmd/test/command/cmd_parse_table_test.go (about) 1 package main 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/easysoft/zendata/cmd/command/action" 8 "github.com/easysoft/zendata/cmd/test/consts" 9 testHelper "github.com/easysoft/zendata/cmd/test/helper" 10 fileUtils "github.com/easysoft/zendata/pkg/utils/file" 11 "github.com/easysoft/zendata/pkg/utils/vari" 12 "github.com/ozontech/allure-go/pkg/framework/provider" 13 "github.com/ozontech/allure-go/pkg/framework/suite" 14 ) 15 16 func TestParseTableCmd(t *testing.T) { 17 suite.RunSuite(t, new(ParseTableCmdSuite)) 18 } 19 20 type ParseTableCmdSuite struct { 21 suite.Suite 22 } 23 24 func (s *ParseTableCmdSuite) BeforeAll(t provider.T) { 25 testHelper.BeforeAll() 26 t.AddSubSuite("ParseTableCmd") 27 } 28 func (s *ParseTableCmdSuite) BeforeEach(t provider.T) { 29 testHelper.PreCase() 30 t.AddSubSuite("ParseTableCmd") 31 } 32 func (s *ParseTableCmdSuite) AfterEach(t provider.T) { 33 testHelper.PostCase() 34 } 35 36 func (s *ParseTableCmdSuite) TestParseSql(t provider.T) { 37 t.ID("0") 38 39 vari.GlobalVars.Output = filepath.Dir(consts.CommandTestFileTablesOut) 40 41 action.GenYaml(consts.CommandTestFileTables) 42 43 out := fileUtils.ReadFile(filepath.Join(consts.CommandTestFileTablesOut)) 44 45 t.Require().Contains(out, "from: keys.yaml", "check parse sql") 46 } 47 48 func (s *ParseTableCmdSuite) TestParseArticle(t provider.T) { 49 t.ID("0") 50 51 vari.GlobalVars.Output = filepath.Dir(consts.CommandTestFileArticleOut) 52 53 action.GenYaml(consts.CommandTestFileArticle) 54 55 out := fileUtils.ReadFile(filepath.Join(consts.CommandTestFileArticleOut)) 56 57 t.Require().Contains(out, "{时间}{人称代词}", "check parse article") 58 }