This repository was archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Unable to import Google's protobuf libs #23
Copy link
Copy link
Open
Description
Describe the bug
I'm unable to import the protobuf libraries developed by Google which is a basic requirement to develop test that have the the protobuf generated code inside.
To Reproduce
Steps to reproduce the behavior:
- Run Replicant v0.2.1
- Copy the Go example presented in the Readme
- Add the import for the proto libs
- Invoke the
/api/v1/run - Observe the
"error": "driver/go: error initializing transaction script: 9:3: import \"github.com/golang/protobuf/proto\" error: unable to find source related to: \"github.com/golang/protobuf/proto\""
Expected behavior
i expected Replicant to detect and fetch the dependencies so that it could run such tests.
The request payload
name: duckduckgo-api-search
driver: go
schedule: '@every 60s'
timeout: 60s
retry_count: 2
inputs:
url: "https://api.duckduckgo.com"
text: "blade runner"
metadata:
transaction: api-search
application: duckduckgo
environment: production
component: api
script: |
package transaction
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: translation.proto
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
"bytes"
"context"
"fmt"
"net/http"
"io/ioutil"
"net/http"
"regexp"
)
//The protobuf generated code is omitted due to business reasons
func Run(ctx context.Context) (m string, d string, err error) {
req, err := http.NewRequest(http.MethodGet, "{{ index . "url" }}", nil)
if err != nil {
return "request build failed", "", err
}
req.Header.Add("Accept-Charset","utf-8")
q := req.URL.Query()
q.Add("q", "{{ index . "text" }}")
q.Add("format", "json")
q.Add("pretty", "1")
q.Add("no_redirect", "1")
req.URL.RawQuery = q.Encode()
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return "failed to send request", "", err
}
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "failed to read response", "", err
}
rx, err := regexp.Compile(`"Text"\s*:\s*"(.*?)"`)
if err != nil {
return "failed to compile regexp", "", err
}
s := rx.FindSubmatch(buf)
if len(s) < 2 {
return "failed to find data", "", fmt.Errorf("no match")
}
return "search result", fmt.Sprintf("%s", s[1]), nil
}
Metadata
Metadata
Assignees
Labels
No labels
