Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ jobs:
version: v1.62.2
args: --verbose --timeout=3m

- name: Build examples
run: make build-examples

- name: Test
run: make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# .env files
.env

# Generated CSV files
*.csv
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ lint: linters-install
test:
$(GOCMD) test -v -cover -race ./...

.PHONY: test lint linters-install
build-examples:
$(GOCMD) build ./examples/...

.PHONY: test lint linters-install build-examples
6 changes: 3 additions & 3 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func main() {
// Add a single test case
if err := qasCSV.AddTestCase(qascsv.TestCase{
Title: "Changing to corresponding cursor after hovering the element",
Folder: []string{"Bistro Delivery", "About Us"},
FolderPath: []string{"Bistro Delivery", "About Us"},
Priority: "low",
Tags: []string{"About Us", "Checklist", "REQ-4", "UI"},
Preconditions: "The \"About Us\" page is opened",
Expand All @@ -28,7 +28,7 @@ func main() {
// Add multiple test cases
if err := qasCSV.AddTestCases([]qascsv.TestCase{{
Title: "Cart should be cleared after making the checkout",
Folder: []string{"Bistro Delivery", "Cart", "Checkout"},
FolderPath: []string{"Bistro Delivery", "Cart", "Checkout"},
Priority: "medium",
Tags: []string{"Cart", "checkout", "REQ-6", "Functional"},
Preconditions: "1. Order is placed\n2. Successful message is shown",
Expand All @@ -41,7 +41,7 @@ func main() {
}},
}, {
Title: "Changing to corresponding cursor after hovering the element",
Folder: []string{"Bistro Delivery", "Cart", "Checkout"},
FolderPath: []string{"Bistro Delivery", "Cart", "Checkout"},
Priority: "low",
Tags: []string{"Checklist", "REQ-6", "UI", "checkout"},
Preconditions: "The \"Checkout\" page is opened",
Expand Down
143 changes: 143 additions & 0 deletions examples/functional/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package main

import (
"log"

qascsv "github.com/hypersequent/qasphere-csv"
)

func main() {
if err := generateFolderComments(); err != nil {
log.Fatal(err)
}
if err := generateEmptyFolders(); err != nil {
log.Fatal(err)
}
if err := generateEscaping(); err != nil {
log.Fatal(err)
}
}

func generateFolderComments() error {
q := qascsv.NewQASphereCSV()

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Commented Folder"},
Comment: "This folder has a comment but also contains test cases",
}); err != nil {
return err
}
if err := q.AddTestCase(qascsv.TestCase{
Title: "Test inside commented folder",
FolderPath: []string{"Commented Folder"},
Priority: qascsv.PriorityHigh,
}); err != nil {
return err
}

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Another Folder"},
Comment: "Standalone comment on a folder with no test cases",
}); err != nil {
return err
}

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Parent", "Child With Comment"},
Comment: "Nested folder comment",
}); err != nil {
return err
}
if err := q.AddTestCase(qascsv.TestCase{
Title: "Test in parent folder",
FolderPath: []string{"Parent"},
Priority: qascsv.PriorityMedium,
}); err != nil {
return err
}

if err := q.WriteCSVToFile("folder_comments.csv"); err != nil {
return err
}
log.Println("wrote folder_comments.csv")
return nil
}

func generateEmptyFolders() error {
q := qascsv.NewQASphereCSV()

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Empty Root Folder"},
}); err != nil {
return err
}
if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Parent", "Empty Child"},
}); err != nil {
return err
}
if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Parent", "Another Empty Child"},
}); err != nil {
return err
}
if err := q.AddTestCase(qascsv.TestCase{
Title: "Test in parent alongside empty children",
FolderPath: []string{"Parent"},
Priority: qascsv.PriorityLow,
}); err != nil {
return err
}

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Deep", "Nested", "Empty"},
}); err != nil {
return err
}

if err := q.WriteCSVToFile("empty_folders.csv"); err != nil {
return err
}
log.Println("wrote empty_folders.csv")
return nil
}

func generateEscaping() error {
q := qascsv.NewQASphereCSV()

if err := q.AddTestCase(qascsv.TestCase{
Title: "Test in folder with slash",
FolderPath: []string{"Features/Bugs", "Login"},
Priority: qascsv.PriorityHigh,
}); err != nil {
return err
}
if err := q.AddTestCase(qascsv.TestCase{
Title: "Test in folder with multiple slashes",
FolderPath: []string{"A/B/C", "D/E"},
Priority: qascsv.PriorityMedium,
}); err != nil {
return err
}

if err := q.AddFolder(qascsv.Folder{
FolderPath: []string{"Empty/Slash/Folder"},
Comment: "This empty folder name contains slashes",
}); err != nil {
return err
}

if err := q.AddTestCase(qascsv.TestCase{
Title: "Test in normal folder for comparison",
FolderPath: []string{"Normal Folder", "Subfolder"},
Priority: qascsv.PriorityLow,
}); err != nil {
return err
}

if err := q.WriteCSVToFile("escaping.csv"); err != nil {
return err
}
log.Println("wrote escaping.csv")
return nil
}
Loading