Bash Unit (Current Choice)

References

Example testing for negative case

test__json.is_json__false(){
  json.is_json 'This is not a JSON' && fail "Expected false"

  return 0
}

General examples

test__json.get_field__with_spaces(){
  local name=$(echo '{"name":"John Jameson", "age":31, "city":"New York"}' | json.get_field "name")
  assert_equals "John Jameson" "${name:?}"
}

test__json.get_field__int(){
  local age=$(echo '{"name":"John Jameson", "age":31, "city":"New York"}' | json.get_field "age")
  assert_equals "31" "${age:?}"
}


test__json.is_json__true(){
  json.is_json '{"name":"John Jameson", "age":31, "city":"New York"}' || fail "Expected true"
}

#current-choice


Backlinks