Documentation ¶
Overview ¶
Package firetest provides utilities for Firebase testing
Example ¶
package main import ( "io/ioutil" "log" "net/http" "strings" "github.com/zabawaba99/firego/internal/firetest" ) func main() { ft := firetest.New() defer ft.Close() ft.Start() resp, err := http.Post(ft.URL+"/foo.json", "application/json", strings.NewReader(`{"bar":true}`)) if err != nil { log.Fatal(err) } defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatal(err) } log.Printf("Post Resp: %s\n", string(b)) v := ft.Get("foo/bar") log.Printf("Value: %v", v) }
Output:
Index ¶
- type Firetest
- func (ft *Firetest) Close()
- func (ft *Firetest) Create(path string, v interface{}) string
- func (ft *Firetest) Delete(path string)
- func (ft *Firetest) Get(path string) (v interface{})
- func (ft *Firetest) RequireAuth(v bool)
- func (ft *Firetest) Set(path string, v interface{})
- func (ft *Firetest) Start()
- func (ft *Firetest) Update(path string, v interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Firetest ¶
type Firetest struct { // URL of form http://ipaddr:port with no trailing slash URL string // Secret used to authenticate with server Secret string // contains filtered or unexported fields }
Firetest is a Firebase server implementation
func (*Firetest) Create ¶
Create generates a new child under the given location using a unique name and returns the name
Reference https://www.firebase.com/docs/rest/api/#section-post
func (*Firetest) Delete ¶
Delete removes the data at the requested location. Any data at child locations will also be deleted.
Reference https://www.firebase.com/docs/rest/api/#section-delete
func (*Firetest) Get ¶
Get retrieves the data and all its children at the requested location
Reference https://www.firebase.com/docs/rest/api/#section-get
func (*Firetest) RequireAuth ¶
RequireAuth determines whether or not a Firetest server will require that each request be authorized
func (*Firetest) Set ¶
Set writes data to at the given location. This will overwrite any data at this location and all child locations.
Reference https://www.firebase.com/docs/rest/api/#section-put
func (*Firetest) Update ¶
Update writes the enumerated children to this the given location. This will overwrite only children enumerated in the "value" parameter and will leave others untouched. Note that the update function is equivalent to calling Set() on the named children; it does not recursively update children if they are objects. Passing null as a value for a child is equivalent to calling remove() on that child.
Reference https://www.firebase.com/docs/rest/api/#section-patch