GithubHelp home page GithubHelp logo

tile38-mock's Introduction

Tile38 Mock

This project will make up a mock server for Tile38 that you can define your desired responses with respect of passed command. It can run on a port and you can communicate with it by redis protocol. Best for testing your application with low overhead.

Using

To start using Tile38 Mock install go and get it with:

go get -u github.com/anvari1313/tile38-mock

How to use it

Each instance of tile38_mock.MockServer is responsible for an instance of tile38 server.

  1. First of all import the package
  2. Create a new instance with CreateMockServer.
  3. Set commands and their responses with SetStringResponse.
  4. Init the server with address and port.

Sample Code:

import "github.com/anvari1313/tile38-mock"

...

s := tile38_mock.CreateMockServer() // Create a new mock server instance

// Set command and responses
s.SetStringResponse([]string{"set", "key", "value"}, []string{"OK"})        // SET KEY VALUE -> OK
s.SetStringResponse([]string{"get", "key"}, []string{"VALUE"})              // GET KEY -> VALUE 
s.SetStringResponse([]string{"got", "key"}, []string{"VALUE1", "VALUE1"})   // GOT KEY -> 1)VALUE1 2)VALUE2

_ = s.Init(":1024") // Run the server on port 1024

NOTE: Be aware that tcp server will run in a separate go routine and the init function is non blocking.

tile38-mock's People

Contributors

anvari1313 avatar

Stargazers

 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.