go-iokit

module
v0.0.0-...-9df9962 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: Apache-2.0

README

CircleCI Maintainability Test Coverage Go Report Card License

 // S3Url uses S3_*_URL environment variables
 // export S3_DOTEST_URL=s3://id:secret@nyc3.digitaloceanspaces.com/bucket/prefix
 // export S3_AWSTEST_URL=s3://id:secret@s3.us-west-2.amazonaws.com/bucket/prefix
 // s3://$cerds/path means to use credentials form environment valiable S3_CREDS_URL
 // s3://$/bucket/path means to use default aws credentials
 //
 // GsUrl uses GS_*_URL environment variables
 // export GS_ENCTEST_URL=json://bucket:prefix:password:/abs/path/to/servicecredentials.json.enc
 // export GS_TEST_URL=json://bucket:prefix::/abs/path/to/servicecredentials.json
 // gs://$creds/path menas to use credentials form enviroment variable GS_CREDS_URL
 // gs://$/bucket/path means to use default google cloud credentials
 //
 // File url can use any environment variable
 // export FILES=.

// Write and read back 
func Test_Example(t *testing.T) {
    for _,url := range []string{
                        "s3://$awstest/test_example.txt",
                        "gs://$enctest/test_example.txt",
                        "file://$files/test_example.txt"} {
        
        S := fmt.Sprintf(`Hello world! %d`, rand.Int())
    
        wh,err := iokit.Url(url).Create()
        assert.NilError(t,err)
        defer wh.End()
        _,err = wh.Write([]byte(S))
        assert.NilError(t,err)
        err = wh.Commit()
        assert.NilError(t,err)
    
        rd,err := iokit.Url(url).Open()
        assert.NilError(t,err)
        defer rd.Close()
        q,err := ioutil.ReadAll(rd)
        assert.NilError(t,err)
        assert.Assert(t,string(q)==S)
    }
}

Directories

Path Synopsis
fu
gcp
s3p

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL