mercredi 24 avril 2019

Golang unit testing command issue

I have a golang code which uses ipfs daemon, ipfs-cluster daemon as a dependency, I have build test cases for all the function(all the function are having a dependency on ipfs daemon, ipfs-cluster daemon both running in background) When I am using command go test -v to test a specific package in my go code, i am able to do it successfully for all the packages and all test are passing but when i am trying to test all the packages together using go test -v ./... I am getting panic run time error because daemon is initializing again and again. Can anyone suggest why this is happening? Is it because of concurrency in test cases? If so how can I solve it?

I have tried to initialize daemon just for one package, I have also tried to initialize daemon for all the packages but nothing is working

precondition // to initialize both the daemons 
    req, _ := http.NewRequest("type", "request")

    router := httprouter.New()
    router.RedirectTrailingSlash = true


    rr := httptest.NewRecorder()
    router.GET("path", handler)

    router.ServeHTTP(rr, req)
    status := rr.Code

when testing a single package using go get -v all test case are passing but when testing all the packages together using go get -v ./... getting run time error

Aucun commentaire:

Enregistrer un commentaire