Skip to content

Commit

Permalink
Merge pull request #403 from jbampton/fix-build-step
Browse files Browse the repository at this point in the history
Try a simple Go test on CircleCI
  • Loading branch information
jbampton committed Feb 18, 2020
2 parents 7102fad + 204947f commit f55b743
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ jobs:
- run:
name: 🧹 Run Golang revive lint
command: |
cd scrapers/go
sh ./check-revive.sh || exit 1
- run:
name: 🧪 Run Go test
command: |
go test -race -covermode atomic -coverprofile=profile.cov ./...
- save_cache: # Store cache in the /go/pkg directory
key: v1-pkg-cache
paths:
Expand Down
2 changes: 0 additions & 2 deletions scrapers/go/check-revive.sh → check-revive.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

cd ../ || exit

# print first
revive -config config.toml .

Expand Down
10 changes: 10 additions & 0 deletions scrapers/go/colly/github/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func main() {
var delay int
var username string
app := &cli.App{
Flags: []cli.Flag{
Expand All @@ -22,6 +23,14 @@ func main() {
Destination: &username,
Required: true,
},
&cli.IntFlag{
Name: "delay",
Aliases: []string{"d"},
Usage: "Time to delay in seconds",
Destination: &delay,
Required: false,
Value: 60,
},
},
Action: func(c *cli.Context) error {
return nil
Expand All @@ -31,6 +40,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
time.Sleep(time.Duration(delay) * time.Second)
record := scrape(username)
fmt.Println(record)
}
Expand Down
20 changes: 18 additions & 2 deletions scrapers/go/colly/github/main_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
package main

import "testing"
import (
"strconv"
"testing"
"time"
)

func TestSimple(t *testing.T) {
func TestLength(t *testing.T) {
got := len(scrape("jbampton"))
if got != 5 {
t.Errorf("len(scrape(\"jbampton\")) = %d; want 5", got)
}
}

func TestIntegers(t *testing.T) {
time.Sleep(15 * time.Second)
got := scrape("prestonhunter")
for _, v := range got {
i, _ := strconv.Atoi(v)
s := strconv.Itoa(i)
if v != s {
t.Errorf("scrape(\"prestonhunter\") = %s; want all numeric", got)
}
}
}

0 comments on commit f55b743

Please sign in to comment.