-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from igor-sikachyna/versioning-support
Query versioning support
- Loading branch information
Showing
12 changed files
with
427 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,13 @@ jobs: | |
- name: Display Go version | ||
run: go version | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: '8.0' | ||
|
||
- name: Run tests | ||
run: go test | ||
run: go test ./... | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,10 @@ jobs: | |
- name: Display Go version | ||
run: go version | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: '8.0' | ||
|
||
- name: Run tests | ||
run: go test | ||
run: go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
func GetFileHash(path string) (hash string, err error) { | ||
file, err := os.Open(path) | ||
if err != nil { | ||
return | ||
} | ||
defer file.Close() | ||
|
||
var hashFunction = sha256.New() | ||
_, err = io.Copy(hashFunction, file) | ||
if err != nil { | ||
return | ||
} | ||
|
||
hash = fmt.Sprintf("%x", hashFunction.Sum(nil)) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetFileHashValid(t *testing.T) { | ||
var assert = assert.New(t) | ||
|
||
var hash, err = GetFileHash("hash_test.go") | ||
assert.Equal(nil, err, "Returned an error 1") | ||
assert.Equal(64, len(hash), "Incorrect hash length 1") | ||
|
||
hash, err = GetFileHash("test/example.txt") | ||
assert.Equal(nil, err, "Returned an error 2") | ||
assert.Equal("a9a66978f378456c818fb8a3e7c6ad3d2c83e62724ccbdea7b36253fb8df5edd", hash, "Incorrect hash length 2") | ||
} | ||
|
||
func TestGetFileHashInvalid(t *testing.T) { | ||
var assert = assert.New(t) | ||
|
||
var _, err = GetFileHash("invalid.exe") | ||
assert.NotEqual(nil, err, "Did not return an error 1") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.