mirror of
https://github.com/ChronosX88/go-gun.git
synced 2024-11-09 20:51:00 +00:00
33 lines
779 B
Go
33 lines
779 B
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cretz/esgopeta/gun"
|
|
)
|
|
|
|
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", "TestGunGetSimple", "some-key").Val(ctx)
|
|
ctx.Require.NoError(f.Err)
|
|
// Make sure we got back the same value
|
|
ctx.Require.Equal(gun.ValueString(randStr), f.Value.Value.(gun.ValueString))
|
|
|
|
}
|