Skip to content

Commit

Permalink
Add sanity checks (#174)
Browse files Browse the repository at this point in the history
* [feature] add sanity checks

* feat: add runner to run sanity checks flow

---------

Co-authored-by: Mathieu Gabelle <[email protected]>
  • Loading branch information
Ben8t and mgabelle authored Jan 28, 2025
1 parent addff1a commit 32ad96c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/io/kestra/plugin/fs/RunnerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.kestra.plugin.fs;

import io.kestra.core.junit.annotations.ExecuteFlow;
import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.State;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

@KestraTest(startRunner = true)
class RunnerTest {
@Test
@ExecuteFlow("sanity-checks/download.yaml")
void download(Execution execution) {
assertThat(execution.getTaskRunList(), hasSize(2));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}

@Test
@ExecuteFlow("sanity-checks/request.yaml")
void request(Execution execution) {
assertThat(execution.getTaskRunList(), hasSize(2));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}
}
13 changes: 13 additions & 0 deletions src/test/resources/sanity-checks/download.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: download
namespace: qa

tasks:
- id: download
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv

- id: assert
type: io.kestra.plugin.core.execution.Assert
conditions:
- "{{ outputs.download.length == 5837 }}"
- "{{ outputs.download.code == 200 }}"
13 changes: 13 additions & 0 deletions src/test/resources/sanity-checks/request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id: request
namespace: qa

tasks:
- id: request
type: io.kestra.plugin.core.http.Request
uri: https://dummyjson.com/products

- id: assert
type: io.kestra.plugin.core.execution.Assert
conditions:
- "{{ outputs.request.code == 200 }}"
- "{{ json(outputs.request.body).products[0].id == 1}}"

0 comments on commit 32ad96c

Please sign in to comment.