-
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.
chore: Fix flags and add tests (#36)
- Loading branch information
1 parent
023ae85
commit f5dd326
Showing
12 changed files
with
161 additions
and
82 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
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
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,62 @@ | ||
package main_test | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"path" | ||
"strings" | ||
"testing" | ||
) | ||
import "nrversions" | ||
|
||
func Test_RenderCompatDoc(t *testing.T) { | ||
outFilePath := path.Join(os.TempDir(), "compat.md") | ||
outFile, err := os.OpenFile(outFilePath, os.O_CREATE|os.O_RDWR, os.ModePerm) | ||
require.Nil(t, err) | ||
|
||
t.Cleanup(func() { | ||
os.Remove(outFilePath) | ||
}) | ||
|
||
_, err = outFile.WriteString("{/* begin: compat-table */}\n{/* end: compat-table */}") | ||
require.Nil(t, err) | ||
|
||
args := []string{ | ||
"--no-externals", | ||
"--repo-dir", ".", | ||
"--test-dir", "testdata/versioned", | ||
"--ai-compat-json", "testdata/ai-compat.json", | ||
"--replace-in-file", outFilePath, | ||
} | ||
err = main.Run(args) | ||
require.Nil(t, err) | ||
|
||
fileData, err := os.ReadFile(outFilePath) | ||
require.Nil(t, err) | ||
err = outFile.Close() | ||
require.Nil(t, err) | ||
|
||
found := string(fileData) | ||
|
||
// Verify that all of the modules are found and their minimum versions | ||
// are listed correctly. We can't compare against a static document because | ||
// we can't override private methods in a `_test` package. As a result, this | ||
// test does hit npmjs.com to find the latest version of each package. So | ||
// the result will change according to whatever versions are available each | ||
// time the test is run. | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/client-bedrock-runtime` | 3.474.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/client-dynamodb` | 3.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/client-sns` | 3.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/client-sqs` | 3.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/lib-dynamodb` | 3.377.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@aws-sdk/smithy-client` | 3.47.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@elastic/elasticsearch` | 7.16.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@koa/router` | 8.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`@langchain/core` | 0.1.17")) | ||
assert.Equal(t, true, strings.Contains(found, "`@smithy/smithy-client` | 2.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`koa` | 2.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`koa-route` | 3.0.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`koa-router` | 7.1.0")) | ||
assert.Equal(t, true, strings.Contains(found, "`mongodb` | 2.1.0")) | ||
} |
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,13 @@ | ||
{ | ||
"name": "missing-test-target", | ||
"targets": [{ "name": "foo", "minAgentVersion": "1.0.0" }], | ||
"tests": [ | ||
{ | ||
"dependencies": { | ||
"bar": { | ||
"versions": "latest" | ||
} | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.