Skip to content

Commit

Permalink
major refactoring of project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwelin committed Jan 16, 2020
1 parent 33b7e81 commit 85e9601
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 434 deletions.
219 changes: 0 additions & 219 deletions cli.go

This file was deleted.

9 changes: 0 additions & 9 deletions main.go

This file was deleted.

2 changes: 1 addition & 1 deletion fileops.go → pkg/client/fileops.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package client

import (
"bufio"
Expand Down
10 changes: 5 additions & 5 deletions helpers.go → pkg/client/helpers.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package main
package client

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

// Checks if string is valid URL
func isValidURL(urlStr string) bool {
// IsValidURL checks if string is valid URL
func IsValidURL(urlStr string) bool {
u, err := url.Parse(urlStr)
return err == nil && u.Scheme != "" && u.Host != ""
}

// Split string on colon and return a slice
func splitHeader(header string) (int, []string) {
// SplitHeader splits string on colon and return a slice
func SplitHeader(header string) (int, []string) {
splitted := strings.Split(header, ":")
return len(splitted), splitted

Expand Down
6 changes: 3 additions & 3 deletions helpers_test.go → pkg/client/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package client

import "testing"

Expand Down Expand Up @@ -37,7 +37,7 @@ var testTLSScheme = []struct {

func TestValidURL(t *testing.T) {
for i, tt := range testURL {
actual := isValidURL(tt.in)
actual := IsValidURL(tt.in)
if actual != tt.expected {
t.Errorf("test: %d, isValidURL(%s): expected %t, actual %t", i+1, tt.in, tt.expected, actual)
}
Expand All @@ -46,7 +46,7 @@ func TestValidURL(t *testing.T) {

func TestSplitHeaders(t *testing.T) {
for i, tt := range testHeader {
actual, _ := splitHeader(tt.in)
actual, _ := SplitHeader(tt.in)
if actual != tt.expected {
t.Errorf("test: %d, splitHeader(%s): expected %d, actual %d", i+1, tt.in, tt.expected, actual)
}
Expand Down
Loading

0 comments on commit 85e9601

Please sign in to comment.