Skip to content
This repository has been archived by the owner on Dec 25, 2022. It is now read-only.

Commit

Permalink
add basic tests for website & dns targets, fix link with slash
Browse files Browse the repository at this point in the history
  • Loading branch information
erkexzcx committed Mar 5, 2022
1 parent d9440c4 commit 1af08b1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ BINARY_NAME=stoppropaganda
mkdir -p ./dist
rm -rf ./dist/*

# Run tests
go test ./...

# Build binaries
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o "dist/${BINARY_NAME}_v${VERSION}_linux_i386" cmd/stoppropaganda/main.go # Linux i386
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o "dist/${BINARY_NAME}_v${VERSION}_linux_x86_64" cmd/stoppropaganda/main.go # Linux 64bit
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o "dist/${BINARY_NAME}_v${VERSION}_linux_arm" cmd/stoppropaganda/main.go # Linux armv5/armel/arm (it also works on armv6)
Expand Down
14 changes: 14 additions & 0 deletions internal/targets/dns_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package targets

import (
"strings"
"testing"
)

func TestDNSTargets(t *testing.T) {
for k := range TargetDNSServers {
if !strings.HasSuffix(k, ":53") {
t.Errorf("Invalid DNS target '%s'", k)
}
}
}
2 changes: 1 addition & 1 deletion internal/targets/websites.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ var TargetWebsites = map[string]struct{}{
"https://www.belapb.by": {},
"https://bankdabrabyt.by": {},
"https://belinvestbank.by/individual": {},
"https://api.belinvestbank.by/": {},
"https://api.belinvestbank.by": {},
"https://belpost.by": {},

// by business
Expand Down
19 changes: 19 additions & 0 deletions internal/targets/websites_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package targets

import (
"net/url"
"strings"
"testing"
)

func TestWebsitesLinks(t *testing.T) {
for k := range TargetWebsites {
if strings.HasSuffix(k, "/") {
t.Errorf("Invalid website '%s': ends with slash", k)
}
_, err := url.ParseRequestURI(k)
if err != nil {
t.Errorf("Invalid website '%v':", err)
}
}
}

0 comments on commit 1af08b1

Please sign in to comment.