firetest

package
v0.0.0-...-73d471d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2017 License: MIT Imports: 15 Imported by: 0

README

firetest

Firebase test server meant for use in unit tests

Implemented
Not Supported

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'awesome things with tests')
  4. Push to the branch (git push origin new-feature)
  5. Create new Pull Request

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

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 New

func New() *Firetest

New creates a new Firetest server

func (*Firetest) Close

func (ft *Firetest) Close()

Close closes the server

func (*Firetest) Create

func (ft *Firetest) Create(path string, v interface{}) string

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

func (ft *Firetest) Delete(path string)

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

func (ft *Firetest) Get(path string) (v interface{})

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

func (ft *Firetest) RequireAuth(v bool)

RequireAuth determines whether or not a Firetest server will require that each request be authorized

func (*Firetest) Set

func (ft *Firetest) Set(path string, v interface{})

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) Start

func (ft *Firetest) Start()

Start starts the server

func (*Firetest) Update

func (ft *Firetest) Update(path string, v interface{})

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL