mirror of
https://github.com/ChronosX88/go-gun.git
synced 2024-11-12 14:01:01 +00:00
29 lines
620 B
Go
29 lines
620 B
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGunGetSimple(t *testing.T) {
|
|
// Run the server, put in one call, get in another, then check
|
|
ctx, cancelFn := newContext(t)
|
|
defer cancelFn()
|
|
ctx.startGunJSServer()
|
|
randStr := randString(30)
|
|
// Write w/ JS
|
|
ctx.runJSWithGun(`
|
|
gun.get('esgopeta-test').get('TestGunGetSimple').get('some-key').put('` + randStr + `', ack => {
|
|
if (ack.err) {
|
|
console.error(ack.err)
|
|
process.exit(1)
|
|
}
|
|
process.exit(0)
|
|
})
|
|
`)
|
|
// Get
|
|
g := ctx.newGunConnectedToGunJS()
|
|
f := g.Scoped(ctx, "esgopeta-test", "TestGunGet", "some-key").Val(ctx)
|
|
ctx.Require.NoError(f.Err)
|
|
|
|
}
|