Skip to content

Commit

Permalink
tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
leoporoli committed Mar 14, 2024
1 parent d35f8bc commit a11b604
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func (suite *KurtosisTypeConstructorTestSuite) TestImageBuildSpecTest() {
suite.packageContentProvider.EXPECT().
GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions).
Times(1).
Return(testBuildContextLocator, nil)
Return(testBuildContextAbsoluteLocator, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePackageFilePath(testContainerImageLocator).
GetOnDiskAbsolutePackageFilePath(testContainerImageAbsoluteLocator).
Times(1).
Return(testOnDiskContainerImagePath, nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func (suite *KurtosisTypeConstructorTestSuite) TestImageBuildSpecTestWithBuildFi
suite.packageContentProvider.EXPECT().
GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions).
Times(1).
Return(testBuildContextLocator, nil)
Return(testModulePackageAbsoluteLocator, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePackageFilePath(testContainerImageLocatorWithBuildFile).
GetOnDiskAbsolutePackageFilePath(testContainerImageAbsoluteLocatorWithBuildFile).
Times(1).
Return(testOnDiskContainerImagePathWithBuildFile, nil)

Expand Down Expand Up @@ -56,5 +56,4 @@ func (t *imageBuildSpecWithBuildFileTest) Assert(typeValue builtin_argument.Kurt
require.Nil(t, err)
require.Equal(t, testOnDiskContainerImagePathWithBuildFile, imageBuildSpec.GetContainerImageFilePath())
require.Equal(t, testOnDiskContextDirPath, imageBuildSpec.GetBuildContextDir())
//require.Equal(t, "", imageBuildSpec.GetTargetStage())
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func (suite *KurtosisTypeConstructorTestSuite) TestImageBuildSpecWithTargetStage
suite.packageContentProvider.EXPECT().
GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions).
Times(1).
Return(testBuildContextLocator, nil)
Return(testModulePackageAbsoluteLocator, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePackageFilePath(testContainerImageLocator).
GetOnDiskAbsolutePackageFilePath(testContainerImageAbsoluteLocator).
Times(1).
Return(testOnDiskContainerImagePath, nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (suite *KurtosisHelperTestSuite) TestImportFile() {
// start with an empty cache to validate it gets populated
moduleGlobalCache := map[string]*startosis_packages.ModuleCacheEntry{}

suite.packageContentProvider.EXPECT().GetModuleContents(testModuleFileName).Return("Hello World!", nil)
suite.packageContentProvider.EXPECT().GetModuleContents(testModuleAbsoluteLocator).Return("Hello World!", nil)
suite.packageContentProvider.EXPECT().GetAbsoluteLocator(testModulePackageId, startosis_constants.PackageIdPlaceholderForStandaloneScript, testModuleRelativeLocator, testNoPackageReplaceOptions).Return(testModuleAbsoluteLocator, nil)

suite.run(&importModuleTestCase{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func (suite *KurtosisTypeConstructorTestSuite) TestNixBuildSpecTest() {
suite.packageContentProvider.EXPECT().
GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions).
Times(1).
Return(testBuildContextLocator, nil)
Return(testModulePackageAbsoluteLocator, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePackageFilePath(testNixFlakeLocator).
GetOnDiskAbsolutePackageFilePath(testNixFlakeAbsoluteLocator).
Times(1).
Return(testOnDiskNixFlakePath, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePath(testBuildContextLocator).
GetOnDiskAbsolutePath(testBuildContextAbsoluteLocator).
Times(1).
Return(testOnDiskContextDirPath, nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type readFileTestCase struct {

func (suite *KurtosisHelperTestSuite) TestReadFile() {
suite.packageContentProvider.EXPECT().GetAbsoluteLocator(testModulePackageId, startosis_constants.PackageIdPlaceholderForStandaloneScript, testModuleRelativeLocator, testNoPackageReplaceOptions).Return(testModuleAbsoluteLocator, nil)
suite.packageContentProvider.EXPECT().GetModuleContents(testModuleFileName).Return("Hello World!", nil)
suite.packageContentProvider.EXPECT().GetModuleContents(testModuleAbsoluteLocator).Return("Hello World!", nil)

suite.run(&readFileTestCase{
T: suite.T(),
Expand All @@ -41,6 +41,6 @@ func (t *readFileTestCase) GetStarlarkCodeForAssertion() string {

func (t *readFileTestCase) Assert(result starlark.Value) {
t.packageContentProvider.AssertCalled(t, "GetAbsoluteLocator", testModulePackageId, startosis_constants.PackageIdPlaceholderForStandaloneScript, testModuleRelativeLocator, testNoPackageReplaceOptions)
t.packageContentProvider.AssertCalled(t, "GetModuleContents", testModuleFileName)
t.packageContentProvider.AssertCalled(t, "GetModuleContents", testModuleAbsoluteLocator)
require.Equal(t, result, starlark.String("Hello World!"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func (suite *KurtosisTypeConstructorTestSuite) TestServiceConfigWithImageBuildSp
suite.packageContentProvider.EXPECT().
GetAbsoluteLocator(testModulePackageId, testModuleMainFileLocator, testBuildContextDir, testNoPackageReplaceOptions).
Times(1).
Return(testBuildContextLocator, nil)
Return(testModulePackageAbsoluteLocator, nil)

suite.packageContentProvider.EXPECT().
GetOnDiskAbsolutePackageFilePath(testContainerImageLocator).
GetOnDiskAbsolutePackageFilePath(testContainerImageAbsoluteLocator).
Times(1).
Return(testOnDiskContainerImagePath, nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@ var (

testSrcPath = "/path/to/file.txt"

testModulePackageId = "github.com/kurtosistech/test-package"
testModuleMainFileLocator = "github.com/kurtosistech/test-package/main.star"
testModuleFileName = "github.com/kurtosistech/test-package/helpers.star"
testModuleRelativeLocator = "./helpers.star"
testModulePackageId = "github.com/kurtosistech/test-package"
testModulePackageAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator(testModulePackageId, "")
testModuleMainFileLocator = "github.com/kurtosistech/test-package/main.star"
testModuleFileName = "github.com/kurtosistech/test-package/helpers.star"
testModuleRelativeLocator = "./helpers.star"

testModuleAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator(testModuleFileName, "")

emptyAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator("", "")

testContainerImageName = "kurtosistech/example-datastore-server"
testBuildContextDir = "./"
testBuildFile = "foo.Dockerfile"
testTargetStage = "builder"
testBuildContextLocator = testModulePackageId
testContainerImageLocator = "github.com/kurtosistech/test-package/Dockerfile"
testContainerImageLocatorWithBuildFile = "github.com/kurtosistech/test-package/foo.Dockerfile"
testOnDiskContextDirPath = "kurtosis-data/test-package"
testOnDiskContainerImagePath = "kurtosis-data/test-package/Dockerfile"
testOnDiskContainerImagePathWithBuildFile = "kurtosis-data/test-package/foo.Dockerfile"
testContainerImageName = "kurtosistech/example-datastore-server"
testBuildContextDir = "./"
testBuildFile = "foo.Dockerfile"
testTargetStage = "builder"
testBuildContextAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator(testModulePackageId, "")
testContainerImageAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator("github.com/kurtosistech/test-package/Dockerfile", "")
testContainerImageAbsoluteLocatorWithBuildFile = startosis_packages.NewPackageAbsoluteLocator("github.com/kurtosistech/test-package/foo.Dockerfile", "")
testOnDiskContextDirPath = "kurtosis-data/test-package"
testOnDiskContainerImagePath = "kurtosis-data/test-package/Dockerfile"
testOnDiskContainerImagePathWithBuildFile = "kurtosis-data/test-package/foo.Dockerfile"

testNixContextDir = "./"
testNixImageName = "test-image"
Expand All @@ -49,7 +50,7 @@ var (
testOnDiskNixContextDirPath = "kurtosis-data/test-package"
testOnDiskNixFlakePath = "kurtosis-data/test-package/server/app/flake.nix"
testOnDiskNixFlakeDir = "kurtosis-data/test-package/server/app"
testNixFlakeLocator = "github.com/kurtosistech/test-package/server/app/flake.nix"
testNixFlakeAbsoluteLocator = startosis_packages.NewPackageAbsoluteLocator("github.com/kurtosistech/test-package/server/app/flake.nix", "")

testRegistryAddr = "http://registry.test.io"
testRegistryUsername = "kurtosis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func getOnDiskImageBuildSpecPaths(
// get on disk directory path of Dockerfile
containerImageAbsoluteLocatorStr := path.Join(contextDirAbsoluteLocator.GetLocator(), defaultContainerImageFileName)
if buildFile != "" {
containerImageAbsoluteLocatorStr = path.Join(containerImageAbsoluteLocatorStr, buildFile)
containerImageAbsoluteLocatorStr = path.Join(contextDirAbsoluteLocator.GetLocator(), buildFile)
}

containerImageAbsoluteLocator := startosis_packages.NewPackageAbsoluteLocator(containerImageAbsoluteLocatorStr, contextDirAbsoluteLocator.GetTagBranchOrCommit())
Expand Down

0 comments on commit a11b604

Please sign in to comment.