Skip to content

Commit

Permalink
feat(core): add sanity check to request task
Browse files Browse the repository at this point in the history
  • Loading branch information
nKwiatkowski committed Feb 6, 2025
1 parent 4c401ce commit d6ffc18
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.kestra.plugin.core.http;

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

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;

@KestraTest(startRunner = true)
public class RequestRunnerTest {

@Test
@ExecuteFlow("sanity-checks/request.yaml")
void logExporter(Execution execution) {
assertThat(execution.getTaskRunList(), hasSize(2));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}

}
16 changes: 16 additions & 0 deletions core/src/test/resources/sanity-checks/request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
id: request
namespace: sanitycheck.plugin.core.http

tasks:
- id: request
type: io.kestra.plugin.core.http.Request
uri: https://www.google.com
method: GET
options:
connectionPoolIdleTimeout: PT1M

- id: assert
type: io.kestra.plugin.core.execution.Assert
errorMessage: "Invalid response code {{ outputs.request.code }}"
conditions:
- "{{ outputs.request.code == 200 }}"

0 comments on commit d6ffc18

Please sign in to comment.