Git Product home page Git Product logo

go-test's Introduction

go-test

This is go library project for test cases.

mock server

You can easily make a mock response for a http request by using this.

//Define httpClient you want to add a patch.
httpClient := http.DefaultClient
//Define a target server with domain and add ResponseHandlers. ResponseHandler contains a mock response and a request should be handled.
testServer := mock.NewTargetServer("google.com").AddResponseHandler(&mock.ResponseHandler{
	WriteToBody: func() []byte {
		return []byte(testBody)
	},
	Path:       "/",
	Method:     http.MethodGet,
	StatusCode: 400,
})
//After PatchClient, every http request using the httpClient will handle the mock request.
clientPatcher := mock.PatchClient(httpClient, testServer)
//RemovePatch will remove all mock handlers from the httpClient.
defer clientPatcher.RemovePatch()

go-test's People

Contributors

urunimi avatar

Watchers

Jueun Zune Seo avatar James Cloos avatar Dio Seung Heo avatar Bang Yongbae (Brice) avatar  avatar Bruce Hyunghui Kim avatar Peter Kim avatar Patrick Bongchul Kim avatar Mir Lim avatar dykim avatar Mati B. Terefe avatar  avatar  avatar moonsub-kim avatar wonhotoss avatar SeongPil Lee avatar Dahae Jeon avatar UdonSari avatar 홍서정 avatar Sam avatar matthew.woo avatar Dominic Donguk Lim avatar Thomas Kim avatar Ernar Kusdavletov  avatar Hyang (Arthur) avatar Byeongkyu Kang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.