Skip to content

Commit

Permalink
chore(structure): Change project structure to use internal package
Browse files Browse the repository at this point in the history
Moved all chkok logic Go files under the internal package,
as these are supposed to be used as structured body of the chkok
program, not a library that needs to be exposed and imported
  • Loading branch information
farzadghanei committed Apr 21, 2024
1 parent 48415d8 commit 9c4773a
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/chkok.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"log"
"os"

"github.com/farzadghanei/chkok"
chkok "github.com/farzadghanei/chkok/internal"
)

// ModeHTTP run checks in http server mode
Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions checks_test.go → internal/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ func TestCheckFileExistingFiles(t *testing.T) {
var check *CheckFile
var got Result
var gotStatus, wantStatus Status
const filePath = "../LICENSE"
wantStatus = StatusDone

check = NewCheckFile("LICENSE")
check = NewCheckFile(filePath)
if got = check.Run(); !got.IsOK {
t.Error("invalid check file, want ok got not ok")
} else if len(got.Issues) > 0 {
Expand Down Expand Up @@ -94,15 +95,15 @@ func TestCheckFileExistingFiles(t *testing.T) {
t.Errorf("invalid check file status, want %v got %v", wantStatus, gotStatus)
}

check = NewCheckFile("LICENSE")
check = NewCheckFile(filePath)
check.fileType = TypeDir
if got = check.Run(); got.IsOK {
t.Error("invalid check dir file, want not ok got ok")
} else if len(got.Issues) != 1 || !strings.Contains(got.Issues[0].Error(), "is not a dir") {
t.Errorf("invalid check dir file, want 1 issue got %v", got.Issues)
}

check = NewCheckFile("LICENSE")
check = NewCheckFile(filePath)
check.minSize = 0
if got = check.Run(); !got.IsOK {
t.Error("invalid check file min size, want ok got not ok")
Expand All @@ -117,7 +118,7 @@ func TestCheckFileExistingFiles(t *testing.T) {
t.Errorf("invalid check file status, want %v got %v", wantStatus, gotStatus)
}

check = NewCheckFile("LICENSE")
check = NewCheckFile(filePath)
check.maxSize = 1024 * 1024 * 100
if got = check.Run(); !got.IsOK {
t.Error("invalid check file max size, want ok got not ok")
Expand All @@ -133,8 +134,9 @@ func TestCheckFileExistingFiles(t *testing.T) {
func TestCheckFileDirectories(t *testing.T) {
var check *CheckFile
var got Result
const filePath = "../cmd"

check = NewCheckFile("cmd")
check = NewCheckFile(filePath)
check.fileType = TypeDir
if got = check.Run(); !got.IsOK {
t.Error("invalid check dir dir, want ok got not ok")
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion conf_test.go → internal/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestReadConfErrors(t *testing.T) {
func TestReadConf(t *testing.T) {
var conf *Conf
var err error
conf, err = ReadConf("examples/config.yaml")
conf, err = ReadConf("../examples/config.yaml")
if err != nil {
t.Errorf("invalid read conf, want nil err got err %v", err)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9c4773a

Please sign in to comment.