mumoshu / variant2

Turn your bash scripts into a modern, single-executable CLI app today
MIT License
141 stars 11 forks source link

doc: example of how to invoke tests #10

Closed osterman closed 4 years ago

osterman commented 4 years ago

what

example variant

#!/usr/bin/env variant

job "hello" {

  parameter "noun" {
    type = string
  }

  exec {
    command = "echo"
    args = [ param.noun ]
  }
}

test "hello" {
  case "world" {
    noun = "world"
    exitstatus = 0
    stdout = "world"
  }

  run "hello world" {

  }

  assert "exitstatus" {
    condition = run.res.exitstatus == case.exitstatus
  }

  assert "output" {
    condition = run.stdout == case.stdout
  }
}
mumoshu commented 4 years ago

@osterman I've added documentation about testing which is available at https://github.com/mumoshu/variant2#writing-tests. Does it work?