-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Hemingway
committed
Dec 10, 2019
1 parent
6799690
commit c0a956a
Showing
11 changed files
with
101 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package backup | ||
|
||
import ( | ||
"github.com/tidwall/sjson" | ||
) | ||
|
||
// Body wraps SJSON for building JSON body strings. | ||
type Body struct { | ||
Str string | ||
} | ||
|
||
// Set sets a JSON path to a value. | ||
func (body Body) Set(path, value string) Body { | ||
res, _ := sjson.Set(body.Str, path, value) | ||
body.Str = res | ||
return body | ||
} | ||
|
||
// SetRaw sets a JSON path to a raw string value. | ||
func (body Body) SetRaw(path, rawValue string) Body { | ||
res, _ := sjson.SetRaw(body.Str, path, rawValue) | ||
body.Str = res | ||
return body | ||
} | ||
|
||
// Req | ||
type Req struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package backup | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestSetRaw tests the Body::SetRaw method. | ||
func TestSetRaw(t *testing.T) { | ||
name := Body{}.SetRaw("a", `{"name":"a"}`).gjson().Get("a.name").Str | ||
assert.Equal(t, "a", name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package backup | ||
|
||
import ( | ||
"github.com/tidwall/gjson" | ||
) | ||
|
||
// Res is an API response returned by client requests. | ||
type Res = gjson.Result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package goaci | ||
package backup | ||
|
||
// Indus RN schema | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters