Skip to content

[Do Not Merge]Unit testing and code structure changes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

# go option
PKG := ./...
TAGS :=
TESTS := .
TESTFLAGS :=
LDFLAGS := -w -s
GOFLAGS :=
SRC := $(shell find . -type f -name '*.go' -print)


.PHONY: all
all: help
Expand All @@ -21,4 +30,15 @@ publish:

.PHONY: build-go
build-go:
go build .
go build .

.PHONY: test
test: build
test: TESTFLAGS += -race -v
test: test-unit

.PHONY: test-unit
test-unit:
@echo
@echo "==> Running unit tests <=="
GO111MODULE=on go test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
38 changes: 38 additions & 0 deletions api/sendPayloadToLogilica.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package api

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"

types "github.com/event-listener/types"
)

func UploadPlanningData(repoId string, payload []types.CiBuildPayload) error {
postBody, _ := json.Marshal(payload)
logilicaUrl := fmt.Sprintf("https://logilica.io/api/import/v1/ci_build/%v/create", repoId)
contentType := "application/json"

client := &http.Client{}
req, err := http.NewRequest("POST", logilicaUrl, bytes.NewBuffer(postBody))
if err != nil {
return err
}
req.Header.Add("Content-Type", contentType)
req.Header.Add("x-lgca-domain", "redhat")
req.Header.Add("X-lgca-token", os.Getenv("LOGILICA_TOKEN"))
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
fmt.Println(string(body))
return nil
}
45 changes: 0 additions & 45 deletions ci_build.go

This file was deleted.

Loading