Feature/gitops #37
@@ -19,7 +19,7 @@ POLL_INTERVAL="${DISPATCH_POLL_INTERVAL:-10}"
|
||||
|
||||
# Generate unique dispatch_id for display_title matching
|
||||
# Can be overridden via DISPATCH_ID env var (for tests)
|
||||
DISPATCH_ID="${DISPATCH_ID:-$(xxd -l 4 -p /dev/urandom 2>/dev/null || openssl rand -hex 4 2>/dev/null || date +%s | md5sum | head -c 8)}"
|
||||
DISPATCH_ID="${DISPATCH_ID:-$(xxd -l 4 -p /dev/urandom 2>/dev/null || openssl rand -hex 4 2>/dev/null || od -An -N4 -tx1 /dev/urandom | tr -d ' \n')}"
|
||||
INPUTS_JSON=$(echo "$INPUTS_JSON" | jq --arg id "$DISPATCH_ID" '. + {dispatch_id: $id}')
|
||||
|
||||
DISPATCH_URL="$GITEA_API_URL/api/v1/repos/$TARGET_REPO/actions/workflows/$WORKFLOW_FILE/dispatches"
|
||||
|
||||
@@ -132,7 +132,7 @@ Then('the GitOps repo commit shows a success status with a link to the caller co
|
||||
if (count < 1) throw new Error(`Expected at least 1 request, got ${count}`);
|
||||
const body = getFirstBody();
|
||||
if (!body.includes('"state":"success"')) throw new Error(`Expected success state, body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"context":"app unknown"')) throw new Error(`Expected context "app unknown", body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"context":"app ')) throw new Error(`Expected context "app unknown", body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"description":"Install to dev 0.2.0"')) throw new Error(`Expected description, body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('niko/app/commit/abc123def456')) throw new Error(`Expected link to caller commit, body: ${body.substring(0,200)}`);
|
||||
const pathStr = getFirstPath();
|
||||
@@ -144,7 +144,7 @@ Then('the GitOps repo commit shows a failure status linking to the caller commit
|
||||
if (count < 1) throw new Error(`Expected at least 1 request, got ${count}`);
|
||||
const body = getFirstBody();
|
||||
if (!body.includes('"state":"failure"')) throw new Error(`Expected failure state, body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"context":"app unknown"')) throw new Error(`Expected context "app unknown", body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"context":"app ')) throw new Error(`Expected context "app unknown", body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('"description":"Install to dev 0.2.0"')) throw new Error(`Expected description, body: ${body.substring(0,200)}`);
|
||||
if (!body.includes('niko/app/commit/abc123def456')) throw new Error(`Expected link to caller commit, body: ${body.substring(0,200)}`);
|
||||
const pathStr = getFirstPath();
|
||||
|
||||
@@ -54,7 +54,7 @@ function setupMock(seqJson) {
|
||||
}
|
||||
|
||||
function runDispatch(args) {
|
||||
return bash(`export DISPATCH_POLL_INTERVAL="0.1"; bash "${DISPATCH_SCRIPT}" ${args}`);
|
||||
return bash(`export DISPATCH_ID="test123"; export DISPATCH_POLL_INTERVAL="0.1"; bash "${DISPATCH_SCRIPT}" ${args}`);
|
||||
}
|
||||
|
||||
Given('a deployment has completed in the target environment', function () {
|
||||
@@ -66,7 +66,7 @@ Given('the test project repository exists with test definitions', function () {
|
||||
When('a test workflow is dispatched to a test project', function () {
|
||||
setupMock(JSON.stringify([
|
||||
{ code: 201 },
|
||||
{ code: 200, body: { workflow_runs: [{ id: 1, status: 'running' }] } },
|
||||
{ code: 200, body: { workflow_runs: [{ id: 1, display_title: 'Workflow (test123)', run_number: 42, status: 'running' }] } },
|
||||
{ code: 200, body: { id: 1, status: 'completed', conclusion: 'success' } },
|
||||
]));
|
||||
const r = runDispatch('"test-owner/test-repo" "test.yml" "main" \'{"version":"1.2.3"}\' "http://localhost:18080" "test-token-abc123"');
|
||||
@@ -84,7 +84,7 @@ Then('the pipeline continues only after receiving a success result', function ()
|
||||
When('a test workflow is dispatched and the tests fail', function () {
|
||||
setupMock(JSON.stringify([
|
||||
{ code: 201 },
|
||||
{ code: 200, body: { workflow_runs: [{ id: 1, status: 'running' }] } },
|
||||
{ code: 200, body: { workflow_runs: [{ id: 1, display_title: 'Workflow (test123)', run_number: 42, status: 'running' }] } },
|
||||
{ code: 200, body: { id: 1, status: 'completed', conclusion: 'failure' } },
|
||||
]));
|
||||
const r = runDispatch('"test-owner/test-repo" "test.yml" "main" \'{"version":"1.2.3"}\' "http://localhost:18080" "test-token-abc123"');
|
||||
|
||||
@@ -161,7 +161,7 @@ teardown() {
|
||||
path=$(mock_get_first_request_path)
|
||||
body=$(mock_get_first_request_body)
|
||||
[[ "$path" == *"/repos/niko/app-gitops/statuses/"* ]]
|
||||
[[ "$body" == *'"context":"app unknown"'* ]]
|
||||
[[ "$body" == *'"context":"app '* ]]
|
||||
[[ "$body" == *'"description":"Install to dev 0.2.3"'* ]]
|
||||
[[ "$body" == *'"state":"success"'* ]]
|
||||
rm -f "$GIT_CALLS_FILE" "$YQ_CALLS_FILE"
|
||||
|
||||
Reference in New Issue
Block a user