From 2ffe749c9d4ced46b0d8d6e23421c5702f8cbc35 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Mon, 7 Oct 2024 16:42:48 +0300 Subject: [PATCH] add driver to group tests --- driver/groupdriver.go | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 driver/groupdriver.go diff --git a/driver/groupdriver.go b/driver/groupdriver.go new file mode 100644 index 0000000..f20d755 --- /dev/null +++ b/driver/groupdriver.go @@ -0,0 +1,60 @@ +package driver + +import ( + "encoding/json" + "os" +) + +type StepTest struct { + Input string `json:"input"` + ExpectedContent string `json:"expectedContent"` +} + +// Group represents a group of steps. +type GroupTest struct { + Name string `json:"name"` + Steps []Step `json:"steps"` +} + +// DataGroup represents the overall structure of the JSON. +type DataGroup struct { + Groups []Group `json:"groups"` +} + +func LoadTestGroups(filePath string) (DataGroup, error) { + var sessionsData DataGroup + data, err := os.ReadFile(filePath) + if err != nil { + return sessionsData, err + } + err = json.Unmarshal(data, &sessionsData) + return sessionsData, err +} + +func CreateTestCases(group DataGroup) []struct { + Name string + Input string + ExpectedContent string +} { + var tests []struct { + Name string + Input string + ExpectedContent string + } + for _, group := range group.Groups { + for _, step := range group.Steps { + // Create a test case for each group + tests = append(tests, struct { + Name string + Input string + ExpectedContent string + }{ + Name: group.Name, + Input: step.Input, + ExpectedContent: step.ExpectedContent, + }) + } + } + + return tests +}