-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
14 changed files
with
227 additions
and
52 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
github: [c-loftus] | ||
custom: ["https://www.paypal.com/paypalme/coltonloftus"] |
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,32 @@ | ||
name: Go Test | ||
|
||
on: | ||
push: | ||
# only trigger on branches, not on tags | ||
branches: '**' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Install Calibre | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y calibre | ||
- name: Ensure ebook-convert is in PATH | ||
run: | | ||
echo "$(dirname $(which ebook-convert)) is in PATH" | ||
ebook-convert --version # This will fail if ebook-convert is not installed correctly | ||
- name: Run Go tests | ||
run: go test ./... -p 1 -count=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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"editor.formatOnType": true, | ||
// hide git ignored files | ||
"explorer.excludeGitIgnore": false | ||
"explorer.excludeGitIgnore": false, | ||
// disable caching for go tests; don't run in parallel since we need to access | ||
// files on the local filesystem | ||
"go.testFlags": ["-count=1", "-p", "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
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,51 @@ | ||
package lib | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestExpandModelPath(t *testing.T) { | ||
// Create a temporary directory for testing | ||
tempDir := t.TempDir() | ||
modelName := "test_model" | ||
modelPath := filepath.Join(tempDir, modelName) | ||
modelJSONPath := modelPath + ".json" | ||
|
||
// Test case 1: Both ONNX and JSON files are present | ||
os.WriteFile(modelPath, []byte("dummy ONNX model"), 0644) | ||
os.WriteFile(modelJSONPath, []byte("dummy JSON"), 0644) | ||
|
||
result, err := ExpandModelPath(modelName, tempDir) | ||
if err != nil || result != modelPath { | ||
t.Errorf("Expected %s, got %s, error: %v", modelPath, result, err) | ||
} | ||
|
||
// Test case 2: ONNX file is present, but JSON file is missing | ||
os.Remove(modelJSONPath) // remove the JSON file | ||
|
||
result, err = ExpandModelPath(modelName, tempDir) | ||
if err == nil || result != "" { | ||
t.Errorf("Expected error for missing JSON file, got: %v, result: %s", err, result) | ||
} | ||
|
||
// Test case 3: Model not found | ||
result, err = ExpandModelPath("non_existent_model", tempDir) | ||
if err == nil || result != "" { | ||
t.Errorf("Expected error for non-existent model, got: %v, result: %s", err, result) | ||
} | ||
|
||
// Test case 4: Model found in the default model directory | ||
modelNameInDir := "another_model" | ||
modelPathInDir := filepath.Join(tempDir, modelNameInDir) | ||
modelJSONPathInDir := modelPathInDir + ".json" | ||
|
||
os.WriteFile(modelPathInDir, []byte("dummy ONNX model"), 0644) | ||
os.WriteFile(modelJSONPathInDir, []byte("dummy JSON"), 0644) | ||
|
||
result, err = ExpandModelPath(modelNameInDir, tempDir) | ||
if err != nil || result != modelPathInDir { | ||
t.Errorf("Expected %s, got %s, error: %v", modelPathInDir, result, err) | ||
} | ||
} |
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 @@ | ||
彩虹,又稱天弓、天虹、絳等,簡稱虹,是氣象中的一種光學現象,當太陽 光照射到半空中的水滴,光線被折射及反射,在天空上形成拱形的七彩光譜,由外 圈至内圈呈紅、橙、黃、綠、蓝、靛蓝、堇紫七种颜色(霓虹則相反)。 |
Oops, something went wrong.