Skip to content

Commit

Permalink
move testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta committed Feb 8, 2025
1 parent 1d9efe1 commit 083cc03
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 21 deletions.
16 changes: 8 additions & 8 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestClient_GetStatus(t *testing.T) {
th := test.Setup(t)

t.Run("Valid", func(t *testing.T) {
dag := th.LoadDAGFile(t, "valid.yaml")
dag := th.DAG(t, filepath.Join("client", "valid.yaml"))
ctx := th.Context

requestID := fmt.Sprintf("request-id-%d", time.Now().Unix())
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestClient_GetStatus(t *testing.T) {
require.Error(t, dagStatus.Error)
})
t.Run("UpdateStatus", func(t *testing.T) {
dag := th.LoadDAGFile(t, "update_status.yaml")
dag := th.DAG(t, filepath.Join("client", "update_status.yaml"))

requestID := "test-update-status"
now := time.Now()
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestClient_GetStatus(t *testing.T) {
})
t.Run("InvalidUpdateStatusWithInvalidReqID", func(t *testing.T) {
wrongReqID := "invalid-request-id"
dag := th.LoadDAGFile(t, "invalid_reqid.yaml")
dag := th.DAG(t, filepath.Join("client", "invalid_reqid.yaml"))
ctx := th.Context
cli := th.Client

Expand All @@ -122,7 +122,7 @@ func TestClient_RunDAG(t *testing.T) {
th := test.Setup(t)

t.Run("RunDAG", func(t *testing.T) {
dag := th.LoadDAGFile(t, "run_dag.yaml")
dag := th.DAG(t, filepath.Join("client", "run_dag.yaml"))
dagStatus, err := th.Client.GetStatus(th.Context, dag.Location)
require.NoError(t, err)

Expand All @@ -134,7 +134,7 @@ func TestClient_RunDAG(t *testing.T) {
require.Equal(t, scheduler.StatusSuccess.String(), status.Status.String())
})
t.Run("Stop", func(t *testing.T) {
dag := th.LoadDAGFile(t, "stop.yaml")
dag := th.DAG(t, filepath.Join("client", "stop.yaml"))
ctx := th.Context

th.Client.StartAsync(ctx, dag.DAG, client.StartOptions{})
Expand All @@ -147,7 +147,7 @@ func TestClient_RunDAG(t *testing.T) {
dag.AssertLatestStatus(t, scheduler.StatusCancel)
})
t.Run("Restart", func(t *testing.T) {
dag := th.LoadDAGFile(t, "restart.yaml")
dag := th.DAG(t, filepath.Join("client", "restart.yaml"))
ctx := th.Context

err := th.Client.Restart(ctx, dag.DAG, client.RestartOptions{})
Expand All @@ -156,7 +156,7 @@ func TestClient_RunDAG(t *testing.T) {
dag.AssertLatestStatus(t, scheduler.StatusSuccess)
})
t.Run("Retry", func(t *testing.T) {
dag := th.LoadDAGFile(t, "retry.yaml")
dag := th.DAG(t, filepath.Join("client", "retry.yaml"))
ctx := th.Context
cli := th.Client

Expand Down Expand Up @@ -285,7 +285,7 @@ func TestClient_ReadHistory(t *testing.T) {
t.Run("TestClient_Empty", func(t *testing.T) {
ctx := th.Context
cli := th.Client
dag := th.LoadDAGFile(t, "empty_status.yaml")
dag := th.DAG(t, filepath.Join("client", "empty_status.yaml"))

_, err := cli.GetStatus(ctx, dag.Location)
require.NoError(t, err)
Expand Down
13 changes: 0 additions & 13 deletions internal/test/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ func (h Helper) Cleanup() {
_ = os.RemoveAll(h.tmpDir)
}

func (h Helper) LoadDAGFile(t *testing.T, filename string) DAG {
t.Helper()

filePath := filepath.Join(fileutil.MustGetwd(), "testdata", filename)
dag, err := digraph.Load(h.Context, filePath)
require.NoError(t, err)

return DAG{
Helper: &h,
DAG: dag,
}
}

// DAG loads a test DAG from the testdata directory
func (h Helper) DAG(t *testing.T, name string) DAG {
t.Helper()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions internal/testdata/scheduler/invalid_schedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schedule: invalid schedule * * *
steps:
- name: step 1
command: "true"
3 changes: 3 additions & 0 deletions internal/testdata/scheduler/non_scheduled_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: step 1
command: "true"
4 changes: 4 additions & 0 deletions internal/testdata/scheduler/scheduled_job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
schedule: 0 * * * *
steps:
- name: step 1
command: "true"
3 changes: 3 additions & 0 deletions internal/testdata/scheduler/start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: "1"
command: "sleep 1"
6 changes: 6 additions & 0 deletions internal/testdata/scheduler/start_stop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
schedule:
start: "0 * * * *"
stop: "1 * * * *"
steps:
- name: step 1
command: "sleep 100"
3 changes: 3 additions & 0 deletions internal/testdata/scheduler/stop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: "1"
command: "sleep 1"

0 comments on commit 083cc03

Please sign in to comment.