go-gun/gun/tests/gun_test.go

29 lines
620 B
Go
Raw Normal View History

2019-02-22 06:46:19 +00:00
package tests
2019-02-22 18:40:02 +00:00
import (
"testing"
)
func TestGunGetSimple(t *testing.T) {
2019-02-22 06:46:19 +00:00
// Run the server, put in one call, get in another, then check
ctx, cancelFn := newContext(t)
defer cancelFn()
2019-02-22 18:40:02 +00:00
ctx.startGunJSServer()
2019-02-22 06:46:19 +00:00
randStr := randString(30)
2019-02-22 18:40:02 +00:00
// Write w/ JS
ctx.runJSWithGun(`
gun.get('esgopeta-test').get('TestGunGetSimple').get('some-key').put('` + randStr + `', ack => {
2019-02-22 06:46:19 +00:00
if (ack.err) {
console.error(ack.err)
process.exit(1)
}
process.exit(0)
})
`)
2019-02-22 18:40:02 +00:00
// Get
g := ctx.newGunConnectedToGunJS()
f := g.Scoped(ctx, "esgopeta-test", "TestGunGet", "some-key").Val(ctx)
2019-02-22 06:46:19 +00:00
ctx.Require.NoError(f.Err)
}