func TestSimplePostGet(t *testing.T) { post_resp := string(cloud.Post("info", []byte("ABC123"))) get_resp := string(cloud.Get("info?a=1&a=2&b=3")) t.Log(post_resp) t.Log(get_resp) Must(t, strings.Contains(post_resp, "[ABC123]"), "Echo back posted file") Must(t, strings.Contains(get_resp, "b:3"), "Parse single parameters") Must(t, strings.Contains(get_resp, "a:1|2"), "Parse multiple parameters") }
func TestFileTransfer(t *testing.T) { // Raw uploaded := string(cloud.Post("upload?login=important&password=7890&file=numbers.txt", []byte("12345"))) downloaded := string(cloud.Get("download?login=important&password=7890&file=numbers.txt")) t.Log(uploaded) t.Log(downloaded) Must(t, uploaded == "OK", "File upload") Must(t, downloaded == "12345", "File download") // Nicer Must(t, strings.Contains(bad_guy.Upload("scene.txt", []byte("Act I")), "FAIL"), "Upload by a bad guy") // Flow Must(t, good_guy.Upload("scene.txt", []byte("Act I")) == "OK", "Upload") Must(t, string(good_guy.Download("scene.txt")) == "Act I", "Download") }