1- import { afterEach , beforeEach , expect , test } from 'bun:test '
1+ import assert from 'node:assert/strict '
22import { join } from 'node:path'
3+ import { afterEach , beforeEach , test } from 'node:test'
34import { collectAttachments } from './attachments.ts'
45import { makeFile , makeTempDir , removeDir } from './fs.testing.ts'
56
@@ -11,14 +12,15 @@ afterEach(async () => await removeDir(tmpDir))
1112
1213test ( 'collect throws error for unknown filetype' , async ( ) => {
1314 await makeFile ( 'init-cloud' , 'whoopie' , tmpDir )
14- await expect ( ( ) => collectAttachments ( tmpDir ) ) . toThrow (
15- 'init-cloud is an unsupported file type' ,
15+ await assert . rejects (
16+ ( ) => collectAttachments ( tmpDir ) ,
17+ new Error ( 'init-cloud is an unsupported file type' ) ,
1618 )
1719} )
1820
1921test ( 'collect cloud config yml' , async ( ) => {
2022 await makeFile ( 'init-cloud.yml' , '#cloud-config\nwhoopie' , tmpDir )
21- expect ( await collectAttachments ( tmpDir ) ) . toStrictEqual ( [
23+ assert . deepEqual ( await collectAttachments ( tmpDir ) , [
2224 {
2325 path : join ( tmpDir , 'init-cloud.yml' ) ,
2426 content : '#cloud-config\nwhoopie' ,
@@ -31,7 +33,7 @@ test('collect cloud config yml', async () => {
3133
3234test ( 'collect cloud config yaml' , async ( ) => {
3335 await makeFile ( 'init-cloud.yaml' , '#cloud-config\nwhoopie' , tmpDir )
34- expect ( await collectAttachments ( tmpDir ) ) . toStrictEqual ( [
36+ assert . deepEqual ( await collectAttachments ( tmpDir ) , [
3537 {
3638 path : join ( tmpDir , 'init-cloud.yaml' ) ,
3739 content : '#cloud-config\nwhoopie' ,
@@ -44,21 +46,23 @@ test('collect cloud config yaml', async () => {
4446
4547test ( 'collect throws error when yml does not have #cloud-config comment' , async ( ) => {
4648 await makeFile ( 'init-cloud.yml' , 'whoopie' , tmpDir )
47- await expect ( ( ) => collectAttachments ( tmpDir ) ) . toThrow (
48- 'YAML cloud config must start with a #cloud-config comment' ,
49+ await assert . rejects (
50+ ( ) => collectAttachments ( tmpDir ) ,
51+ new Error ( 'YAML cloud config must start with a #cloud-config comment' ) ,
4952 )
5053} )
5154
5255test ( 'collect throws error when yaml does not have #cloud-config comment' , async ( ) => {
5356 await makeFile ( 'init-cloud.yaml' , 'whoopie' , tmpDir )
54- await expect ( ( ) => collectAttachments ( tmpDir ) ) . toThrow (
55- 'YAML cloud config must start with a #cloud-config comment' ,
57+ await assert . rejects (
58+ ( ) => collectAttachments ( tmpDir ) ,
59+ new Error ( 'YAML cloud config must start with a #cloud-config comment' ) ,
5660 )
5761} )
5862
5963test ( 'collect shell script' , async ( ) => {
6064 await makeFile ( 'init-cloud.sh' , 'whoopie' , tmpDir )
61- expect ( await collectAttachments ( tmpDir ) ) . toStrictEqual ( [
65+ assert . deepEqual ( await collectAttachments ( tmpDir ) , [
6266 {
6367 path : join ( tmpDir , 'init-cloud.sh' ) ,
6468 content : 'whoopie' ,
@@ -77,7 +81,7 @@ test('evals template expressions', async () => {
7781 `\${{ file('${ resourceTmpDir } /whoopie') }}` ,
7882 tmpDir ,
7983 )
80- expect ( await collectAttachments ( tmpDir ) ) . toStrictEqual ( [
84+ assert . deepEqual ( await collectAttachments ( tmpDir ) , [
8185 {
8286 path : tmpDir + '/init-cloud.sh' ,
8387 content : 'whoopie' ,
@@ -92,7 +96,7 @@ test('evals template expressions', async () => {
9296test ( 'sorts attachments by filename' , async ( ) => {
9397 await makeFile ( '01-init-cloud.sh' , 'whoopie' , tmpDir )
9498 await makeFile ( '02-init-cloud.sh' , 'whoopie' , tmpDir )
95- expect ( await collectAttachments ( tmpDir ) ) . toStrictEqual ( [
99+ assert . deepEqual ( await collectAttachments ( tmpDir ) , [
96100 {
97101 path : join ( tmpDir , '01-init-cloud.sh' ) ,
98102 content : 'whoopie' ,
0 commit comments