17 lines
468 B
Go
17 lines
468 B
Go
package paymentutil
|
|
|
|
import "testing"
|
|
|
|
func TestNestedAndPathValues(t *testing.T) {
|
|
object := JSONObject([]byte(`{"data":{"status":"SUCCESS","amount":100}}`))
|
|
if got := NestedString(object, "status"); got != "SUCCESS" {
|
|
t.Fatalf("NestedString = %q", got)
|
|
}
|
|
if got := StringAtPath(object, "data.amount"); got != "100" {
|
|
t.Fatalf("StringAtPath = %q", got)
|
|
}
|
|
if got := StringAtPath(object, "data.missing"); got != "" {
|
|
t.Fatalf("missing path = %q", got)
|
|
}
|
|
}
|