Skip to content

Commit 83e2c28

Browse files
committed
fix unit tests
1 parent 52e376d commit 83e2c28

2 files changed

Lines changed: 49 additions & 7 deletions

File tree

.circleci/config.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
version: 2
1+
version: 2.1
22

3-
jobs:
4-
build:
3+
executors:
4+
go-executor:
55
docker:
66
- image: cimg/go:1.23
7-
working_directory: ~/task-tools
7+
working_directory: ~/task-tools
8+
9+
jobs:
10+
test:
11+
executor: go-executor
812
steps:
913
- checkout
1014
- run: go install github.com/jstemmer/go-junit-report/v2@latest
@@ -23,4 +27,36 @@ jobs:
2327
- store_artifacts:
2428
path: ~/task-tools/junit
2529
- store_artifacts:
26-
path: tests.out
30+
path: tests.out
31+
32+
build:
33+
executor: go-executor
34+
steps:
35+
- checkout
36+
- setup_remote_docker:
37+
docker_layer_caching: false
38+
- run:
39+
name: "docker login"
40+
command: echo ${DOCKERHUB_TOKEN} | docker login -u ${DOCKERHUB_USERNAME} --password-stdin
41+
- run:
42+
name: "Push Docker Image"
43+
command: make push
44+
45+
workflows:
46+
version: 2
47+
test_and_build:
48+
jobs:
49+
- test:
50+
filters:
51+
tags:
52+
only:
53+
- /.*/
54+
- build:
55+
requires:
56+
- test
57+
context:
58+
- DOCKER
59+
filters:
60+
tags:
61+
only:
62+
- /.*/

apps/flowlord/taskmaster_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ import (
1515
"github.com/pcelvng/task/bus/nop"
1616
"github.com/robfig/cron/v3"
1717

18+
"github.com/pcelvng/task-tools/apps/flowlord/cache"
1819
"github.com/pcelvng/task-tools/workflow"
1920
)
2021

2122
const base_test_path string = "../../internal/test/"
2223

2324
func TestTaskMaster_Process(t *testing.T) {
2425
delayRegex := regexp.MustCompile(`delayed=(\d+.\d+)`)
25-
cache, fatalErr := workflow.New(base_test_path+"workflow", nil)
26+
workflowCache, fatalErr := workflow.New(base_test_path+"workflow", nil)
2627
if fatalErr != nil {
2728
t.Fatal("cache init", fatalErr)
2829
}
@@ -32,7 +33,12 @@ func TestTaskMaster_Process(t *testing.T) {
3233
}
3334
fn := func(tsk task.Task) ([]task.Task, error) {
3435
var alerts int64
35-
tm := taskMaster{doneConsumer: consumer, Cache: cache, failedTopic: "failed-topic", alerts: make(chan task.Task), slack: &Notification{}}
36+
// Initialize taskCache for the test
37+
taskCache, err := cache.NewSQLite(time.Hour, ":memory:")
38+
if err != nil {
39+
return nil, err
40+
}
41+
tm := taskMaster{doneConsumer: consumer, Cache: workflowCache, taskCache: taskCache, failedTopic: "failed-topic", alerts: make(chan task.Task), slack: &Notification{}}
3642
producer, _ := nop.NewProducer("")
3743
tm.producer = producer
3844
nop.FakeMsg = tsk.JSONBytes()

0 commit comments

Comments
 (0)