-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
138 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file adheres to the YAML5 style. | ||
{ | ||
"name": "Go", | ||
"on": ["push", "pull_request"], | ||
"jobs": { | ||
"build": { | ||
"name": "Build", | ||
"runs-on": "ubuntu-latest", | ||
"steps": [ | ||
{ | ||
"name": "Set up Go 1.19", | ||
"uses": "actions/setup-go@v1", | ||
"with": {"go-version": 1.19}, | ||
"id": "go", | ||
}, | ||
{"name": "Check out code into the Go module directory", "uses": "actions/checkout@v1"}, | ||
{"name": "Linter", "run": "make ci-lint"}, | ||
{"name": "Test", "run": "make 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
GOPATH_DIR=`go env GOPATH` | ||
|
||
test: | ||
go test -v -count=3 . | ||
|
||
ci-lint: | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH_DIR)/bin v1.54.2 | ||
$(GOPATH_DIR)/bin/golangci-lint run ./... | ||
@echo "everything is OK" | ||
|
||
lint: | ||
golangci-lint run ./... | ||
@echo "everything is OK" | ||
|
||
.PHONY: ci-lint lint 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
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,56 @@ | ||
package gdata_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/quasilyte/gdata" | ||
) | ||
|
||
func TestSaveLoad(t *testing.T) { | ||
m, err := gdata.Open(gdata.Config{ | ||
AppName: "gdata_test", | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
const testItemKey = "testitem.txt" | ||
|
||
// Deleting a potentially non-existing item. | ||
// For a second run it acts like a state reset function. | ||
if err := m.DeleteItem(testItemKey); err != nil { | ||
t.Fatalf("delete should never result in an error here (got %v)", err) | ||
} | ||
|
||
if m.ItemExists(testItemKey) { | ||
t.Fatalf("%s item should not exist yet", testItemKey) | ||
} | ||
|
||
data := []byte("example data") | ||
if err := m.SaveItem(testItemKey, data); err != nil { | ||
t.Fatalf("error saving %s data", testItemKey) | ||
} | ||
|
||
if !m.ItemExists(testItemKey) { | ||
t.Fatalf("%s item should exist after a successful save operation", testItemKey) | ||
} | ||
|
||
loadedData, err := m.LoadItem(testItemKey) | ||
if err != nil { | ||
t.Fatalf("loading %s error: %v", testItemKey, err) | ||
} | ||
|
||
if !bytes.Equal(data, loadedData) { | ||
t.Fatalf("saved and loaded data mismatch:\nwant: %q\n have: %q", string(data), string(loadedData)) | ||
} | ||
|
||
// Now we're deleting an existing item. | ||
if err := m.DeleteItem(testItemKey); err != nil { | ||
t.Fatalf("delete should never result in an error here (got %v)", err) | ||
} | ||
|
||
if m.ItemExists(testItemKey) { | ||
t.Fatalf("%s item should not exist after a successful delete operation", testItemKey) | ||
} | ||
} |
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