Skip to content

Commit

Permalink
Move tests to separate package and fix grammar a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed Sep 17, 2021
1 parent f7689b4 commit c02eb4e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/testdata/fresh_project/.regolith/.ignoreme

This file was deleted.

1 change: 0 additions & 1 deletion src/testdata/fresh_project/packs/BP/.ignoreme

This file was deleted.

1 change: 0 additions & 1 deletion src/testdata/fresh_project/packs/RP/.ignoreme

This file was deleted.

16 changes: 9 additions & 7 deletions src/project_test.go → test/project_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package src
package test

import (
"bedrock-oss.github.com/regolith/src"
"crypto/md5"
"encoding/hex"
"io"
Expand All @@ -12,14 +13,12 @@ import (
"testing"
)

// listPaths returns a dircionary with paths of the files from 'path' directory
// listPaths returns a dictionary with paths of the files from 'path' directory
// relative to 'root' directory used as keys, and with md5 hashes paths as
// values. The directory paths use empty strings instead of MD5. The function
// ignores files called .ignoreme (they're used to simulate empty directories
// ignores files called .ignoreme (they simulate empty directories
// in git repository).
func listPaths(path string, root string) (map[string]string, error) {
// 150 is just an arbitrary number I chose to avoid constant memory
// allocation while expanding the slice capacity
result := map[string]string{}
err := filepath.WalkDir(path,
func(path string, data fs.DirEntry, err error) error {
Expand Down Expand Up @@ -79,8 +78,8 @@ func TestRegolithInit(t *testing.T) {
t.Fatal("Unable to change working directory:", err.Error())
}
// Test regolith init
InitLogging(true)
InitializeRegolithProject(false)
src.InitLogging(true)
src.InitializeRegolithProject(false)
createdPaths, err := listPaths(".", ".")
if err != nil {
log.Fatal("Unable to get list of created paths:", err)
Expand All @@ -100,6 +99,9 @@ func TestRegolithInit(t *testing.T) {
} else if createdHash == "" {
t.Fatalf("%q should be a directory but is a file instead", k)
}
// Print the file, that doesn't match
//bytes, _ := ioutil.ReadFile(k)
//t.Log(string(bytes))
t.Fatalf("%q file is different that expected", k)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/testdata/fresh_project/.regolith/.ignoreme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is used for testing to simulate an empty directory because git doesn't allow saving empty directories.
File renamed without changes.
1 change: 1 addition & 0 deletions test/testdata/fresh_project/packs/BP/.ignoreme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is used for testing to simulate an empty directory because git doesn't allow saving empty directories.
1 change: 1 addition & 0 deletions test/testdata/fresh_project/packs/RP/.ignoreme
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is used for testing to simulate an empty directory because git doesn't allow saving empty directories.

0 comments on commit c02eb4e

Please sign in to comment.