Skip to content

Commit

Permalink
[#25] Redirect parse Golden tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aeqz committed Dec 21, 2022
1 parent 029b8cf commit bf6c659
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/golden/check-redirect-parse/bad-code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
to: ^.*$
on: 404
13 changes: 13 additions & 0 deletions tests/golden/check-redirect-parse/bad-on.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
to: ^.*$
on: premanent
11 changes: 11 additions & 0 deletions tests/golden/check-redirect-parse/bad-outcome.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: flow
10 changes: 10 additions & 0 deletions tests/golden/check-redirect-parse/bad-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects: [Bad]
10 changes: 10 additions & 0 deletions tests/golden/check-redirect-parse/bad-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects: Bad
12 changes: 12 additions & 0 deletions tests/golden/check-redirect-parse/bad-to.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
to: 42
93 changes: 93 additions & 0 deletions tests/golden/check-redirect-parse/check-redirect-parse.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bats

# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: MPL-2.0

load '../helpers/bats-support/load'
load '../helpers/bats-assert/load'
load '../helpers/bats-file/load'
load '../helpers'


@test "No redirect rules" {
to_temp xrefcheck -c no-rules.yaml

assert_diff - <<EOF
All repository links are valid.
EOF
}

@test "Only outcome" {
to_temp xrefcheck -c only-outcome.yaml

assert_diff - <<EOF
All repository links are valid.
EOF
}

@test "Only outcome and to" {
to_temp xrefcheck -c only-outcome-to.yaml

assert_diff - <<EOF
All repository links are valid.
EOF
}

@test "Only outcome and on" {
to_temp xrefcheck -c only-outcome-to.yaml

assert_diff - <<EOF
All repository links are valid.
EOF
}

@test "Full rule" {
to_temp xrefcheck -c full-rule.yaml

assert_diff - <<EOF
All repository links are valid.
EOF
}

@test "Rules not an array error" {
run xrefcheck -c bad-rules.yaml

assert_output --partial "expected Array, but encountered String"
}

@test "Rule not an object error" {
run xrefcheck -c bad-rule.yaml

assert_output --partial "expected Object, but encountered String"
}

@test "Bad code error" {
run xrefcheck -c bad-code.yaml

assert_output --partial "expected a redirect (3XX) HTTP code or (permanent|temporary)"
}

@test "Bad on" {
run xrefcheck -c bad-on.yaml

assert_output --partial "expected a redirect (3XX) HTTP code or (permanent|temporary)"
}

@test "Bad to" {
run xrefcheck -c bad-to.yaml

assert_output --partial "expected String, but encountered Number"
}

@test "Bad outcome" {
run xrefcheck -c bad-outcome.yaml

assert_output --partial "expected (valid|invalid|follow)"
}

@test "No outcome error" {
run xrefcheck -c no-outcome.yaml

assert_output --partial "key \"outcome\" not found"
}
13 changes: 13 additions & 0 deletions tests/golden/check-redirect-parse/full-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
to: ^https://.*$
on: permanent
14 changes: 14 additions & 0 deletions tests/golden/check-redirect-parse/no-outcome.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
on: temporary
- to: ^https://.*$
on: temporary
10 changes: 10 additions & 0 deletions tests/golden/check-redirect-parse/no-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects: []
12 changes: 12 additions & 0 deletions tests/golden/check-redirect-parse/only-outcome-on.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: invalid
on: 302
12 changes: 12 additions & 0 deletions tests/golden/check-redirect-parse/only-outcome-to.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: valid
to: ^https://.*$
11 changes: 11 additions & 0 deletions tests/golden/check-redirect-parse/only-outcome.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense

scanners:
markdown:
flavor: GitHub

networking:
externalRefRedirects:
- outcome: follow

0 comments on commit bf6c659

Please sign in to comment.