Skip to content

Commit

Permalink
chore: use load*FromID in tests (dagger#7233)
Browse files Browse the repository at this point in the history
* sdk(rust): use `load*FromID` in tests

Use these newer methods instead of using `container` and `file` to load
IDs, which is deprecated and *going to be removed soon*.

Signed-off-by: Justin Chadwell <[email protected]>

* sdk(go): use load*FromID in tests

Signed-off-by: Justin Chadwell <[email protected]>

* sdk(typescript): use load*FromID in tests

Signed-off-by: Justin Chadwell <[email protected]>

* chore: use load*FromID in tests

Signed-off-by: Justin Chadwell <[email protected]>

---------

Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: kpenfound <[email protected]>
  • Loading branch information
jedevc authored and kpenfound committed May 2, 2024
1 parent aa2f45c commit 4a178a9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
8 changes: 3 additions & 5 deletions core/integration/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2978,9 +2978,7 @@ func TestContainerFromIDPlatform(t *testing.T) {
}).From(alpineImage).ID(ctx)
require.NoError(t, err)

platform, err := c.Container(dagger.ContainerOpts{
ID: id,
}).Platform(ctx)
platform, err := c.LoadContainerFromID(id).Platform(ctx)
require.NoError(t, err)
require.Equal(t, desiredPlatform, platform)
}
Expand Down Expand Up @@ -3956,12 +3954,12 @@ EXPOSE 8080
res := struct {
Container struct {
ExposedPorts []core.Port
}
} `json:"loadContainerFromID"`
}{}

err = testutil.Query(`
query Test($id: ContainerID!) {
container(id: $id) {
loadContainerFromID(id: $id) {
exposedPorts {
port
protocol
Expand Down
4 changes: 2 additions & 2 deletions core/integration/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ func TestContainerPortLifecycle(t *testing.T) {
Protocol dagger.NetworkProtocol
Description *string
}
}
} `json:"loadContainerFromID"`
}{}

getPorts := `query Test($id: ContainerID!) {
container(id: $id) {
loadContainerFromID(id: $id) {
exposedPorts {
port
protocol
Expand Down
6 changes: 2 additions & 4 deletions sdk/go/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestGit(t *testing.T) {
readmeID, err := readmeFile.ID(ctx)
require.NoError(t, err)

otherReadme, err := c.File(readmeID).Contents(ctx)
otherReadme, err := c.LoadFileFromID(readmeID).Contents(ctx)
require.NoError(t, err)
require.Equal(t, readme, otherReadme)
}
Expand Down Expand Up @@ -88,9 +88,7 @@ func TestContainer(t *testing.T) {
id, err := alpine.ID(ctx)
require.NoError(t, err)
contents, err = c.
Container(ContainerOpts{
ID: id,
}).
LoadContainerFromID(id).
File("/etc/alpine-release").
Contents(ctx)
require.NoError(t, err)
Expand Down
7 changes: 2 additions & 5 deletions sdk/rust/crates/dagger-sdk/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn test_git() {
let readme = readme_file.contents().await.unwrap();
assert_eq!(true, readme.find("Dagger").is_some());

let other_readme = c.file(readme_file).contents().await.unwrap();
let other_readme = c.load_file_from_id(readme_file).contents().await.unwrap();

assert_eq!(readme, other_readme);
}
Expand All @@ -73,10 +73,7 @@ async fn test_container() {

let id = alpine.id().await.unwrap();
let contents = client
.container_opts(dagger_sdk::QueryContainerOpts {
id: Some(id),
platform: None,
})
.load_container_from_id(id)
.file("/etc/alpine-release")
.contents()
.await
Expand Down
6 changes: 3 additions & 3 deletions sdk/typescript/api/test/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ describe("TypeScript SDK api", function () {
this.timeout(60000)
connect(async (client: Client) => {
const image = await client
.container({
id: await client
.loadContainerFromID(
await client
.container()
.from("alpine:3.16.2")
.withExec(["apk", "add", "yarn"])
.id(),
})
)
.withMountedCache("/root/.cache", client.cacheVolume("cache_key"))
.withExec(["echo", "foo bar"])
.stdout()
Expand Down

0 comments on commit 4a178a9

Please sign in to comment.