test

package
v0.0.0-...-ef346fd Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MutationAddNote = `` /* 135-byte string literal not displayed */
View Source
var MutationAddTodo = `
mutation ($input: AddTodoInput!){
  addTodo(input: $input) {
    id
    name
	done
	noteId
  }
}
`
View Source
var MutationDeleteNote = `mutation ($input: DeleteNoteInput!) {
  deleteNote(input: $input) {
    id
  }
}`
View Source
var MutationDeleteTodo = `
mutation ($input: DeleteTodoInput!){
  deleteTodo(input: $input) {
    id
    noteId
  }
}
`
View Source
var MutationToggleTodo = `
mutation ($input: ToggleTodoInput!){
  toggleTodo(input: $input) {    
    id
	name
	done
	noteId    
  }
}
`
View Source
var MutationUpdateNote = `` /* 147-byte string literal not displayed */
View Source
var MutationUpdateTodo = `
mutation ($input: UpdateTodoInput!){
  updateTodo(input: $input) {
    id
    name
    done
    noteId
  }
}
`
View Source
var QueryNote = `
query($id: Int!){
  note(id: $id) {
	id
	name    
	todos {
	  id
	  name
	  done
	  noteId
	}
  }
}
`
View Source
var QueryNotes = `
query {
  notes {
	id
	name    
	todos {
	  id
	  name
	  done
	  noteId
	}
  }
}
`

GraphQL `note`

View Source
var QueryTodos = `
query ($noteId: Int!){
  todos(noteId: $noteId) {
    id
    name
    done
    noteId
  }
}
`

GraphQL `todo`

Functions

func FillDataToStore

func FillDataToStore(s *store.Store, userName string, notes []model.NoteWithTodos)

func GraphqlWithInput

func GraphqlWithInput(v interface{}) map[string]interface{}

func LoadTestUsers

func LoadTestUsers(s *store.Store)

func NewDevUserNotesData

func NewDevUserNotesData(testApp *MockApp) []model.NoteWithTodos

func NewTestUserNotesData

func NewTestUserNotesData(testApp *MockApp) []model.NoteWithTodos

Types

type MockApp

type MockApp struct {
	App    *app.App
	RawAPI *httpexpect.Expect // Raw vanilla request with any header pre-injection
	API    *httpexpect.Expect // With test user's auth header bearer token
	// contains filtered or unexported fields
}

func NewMockApp

func NewMockApp() MockApp

Each new test app will fork a new db session and will be cleanup after suite test.

func (*MockApp) Close

func (t *MockApp) Close()

func (*MockApp) GraphqlMustData

func (t *MockApp) GraphqlMustData(query string, opts ...interface{}) *httpexpect.Object

sugar that expects the `data` only no error. It will return the `data` json object.

func (*MockApp) GraphqlMustError

func (t *MockApp) GraphqlMustError(query string, opts ...interface{}) *httpexpect.Array

sugar to expects `errors` but `data` could exist with `null`. It will return the `errors` json array.

func (*MockApp) GraphqlPost

func (t *MockApp) GraphqlPost(query string, opts ...interface{}) *httpexpect.Object

graphql response always http succeed with json body as:

{
 "data": { ... },
 "errors": [ ... ]
}

GraphqlPost is a bit raw graphql API that you need to extract the `data` and `errors` `opts` only supports two optional arguments, 1st argument is `variables` should be a `struct` with json tags or a `map[string]interface{}` that can be converted to a json. The 2nd argument must be a string for `operationName`. If no argument is provided then it will include no `variables` and `operationName`.

Jump to

Keyboard shortcuts

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