# file      : tests/manifest/task-response.testscript
# license   : MIT; see accompanying LICENSE file

test.options += -ts

: valid
:
: Roundtrip the task response manifest.
:
{
  : session-not-empty
  :
  {
    : all-values
    :
    $* <<EOF >>EOF
    : 1
    session: abcd
    challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
    result-url: https://cppget.org/?build-result
    :
    name: libfoo
    version: 1.0
    repository-url: http://pkg.example.org/1/math
    machine: windows_10-msvc_14
    target: x86_64-microsoft-win32-msvc14.0
    EOF

    : no-challenge
    :
    $* <<EOF >>EOF
    : 1
    session: abcd
    result-url: https://cppget.org/?build-result
    :
    name: libfoo
    version: 1.0
    repository-url: http://pkg.example.org/1/math
    machine: windows_10-msvc_14
    target: x86_64-microsoft-win32-msvc14.0
    EOF
  }

  : session-empty
  :
  $* <<EOF >>EOF
  : 1
  session:
  EOF
}

: redefinition
:
{
  : session
  :
  $* <<EOI 2>'stdin:3:1: error: task response session redefinition' == 1
  : 1
  session: abcd
  session: abcd
  EOI

  : challenge
  :
  $* <<EOI 2>'stdin:3:1: error: task response challenge redefinition' == 1
  : 1
  challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
  challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
  EOI

  : result-url
  :
  $* <<EOI 2>'stdin:3:1: error: task response result url redefinition' == 1
  : 1
  result-url: https://cppget.org/?build-result
  result-url: https://cppget.org/?build-result
  EOI
}

: invalid
:
{

  : challenge
  :
  {
    : size
    :
    $* <<EOI 2>'stdin:2:12: error: invalid task response challenge' == 1
    : 1
    challenge: abc
    EOI

    : redundant
    :
    $* <<EOI 2>'stdin:4:1: error: unexpected task response challenge' == 1
    : 1
    session:
    challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
    EOI
  }

  : result-url
  :
  {
    : empty
    :
    $* <<EOI 2>'stdin:2:12: error: empty task response result url' == 1
    : 1
    result-url:
    EOI

    : redundant
    :
    $* <<EOI 2>'stdin:4:1: error: unexpected task response result url' == 1
    : 1
    session:
    result-url: https://cppget.org/?build-result
    EOI
  }

  : task-unexpected
  :
  $* <<EOI 2>'stdin:3:1: error: single task response manifest expected' == 1
  : 1
  session:
  :
  EOI
}

: unknown-name
:
$* <<EOI 2>"stdin:2:1: error: unknown name 'x' in task response manifest" == 1
: 1
x:
EOI

: missed
:
{
  : session
  :
  $* <<EOI 2>'stdin:2:1: error: no task response session specified' == 1
  : 1
  EOI

  : result-url
  :
  $* <<EOI 2>'stdin:4:1: error: no task response result url specified' == 1
  : 1
  session: abc
  challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
  EOI

  : task
  :
  $* <<EOI 2>'stdin:5:1: error: task manifest expected' == 1
  : 1
  session: abcd
  challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73
  result-url: https://cppget.org/?build-result
  EOI
}