github.com/NeowayLabs/nash@v0.2.2-0.20200127205349-a227041ffd50/stdbin/write/write_test.sh (about)

     1  import "./common_test.sh"
     2  
     3  setenv PATH = "./stdbin/write:/bin"
     4  
     5  # FIXME: we need our mktemp
     6  var nonExistentFile = "./here-be-dragons"
     7  
     8  fn clean() {
     9      _, _ <= rm -f $nonExistentFile
    10  }
    11  
    12  clean()
    13  
    14  var out, err, status <= write $nonExistentFile "hello"
    15  assert("", $out, "standard out isnt empty")
    16  assert("", $err, "standard err isnt empty")
    17  assert("0", $status, "status is not success")
    18  
    19  var content, status <= cat $nonExistentFile
    20  assert("0", $status, "status is not success")
    21  assert("hello", $content, "file content is wrong")
    22  
    23  # test append
    24  out, err, status <= write $nonExistentFile "1"
    25  assert("", $out, "standard out isnt empty")
    26  assert("", $err, "standard err isnt empty")
    27  assert("0", $status, "status is not success")
    28  
    29  content, status <= cat $nonExistentFile
    30  assert("0", $status, "status is not success")
    31  assert("hello1", $content, "file content is wrong")
    32  
    33  clean()