Skip to content

Commit

Permalink
add bunTask unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
harrel56 committed Oct 8, 2023
1 parent e969425 commit 4467f28
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/test/groovy/com/github/gradle/node/bun/task/BunTaskTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.github.gradle.node.bun.task

import com.github.gradle.node.pnpm.task.PnpmTask
import com.github.gradle.node.task.AbstractTaskTest
import com.github.gradle.node.util.PlatformHelperKt

class BunTaskTest extends AbstractTaskTest {
def "exec bun task"() {
given:
nodeExtension.resolvedPlatform.set(PlatformHelperKt.parsePlatform("Linux", "x86_64", {}))

def task = project.tasks.create('simple', BunTask)
mockProjectApiHelperExec(task)
task.args.set(['a', 'b'])
task.environment.set(['a': '1'])
task.ignoreExitValue.set(true)
task.workingDir.set(projectDir)

when:
project.evaluate()
task.exec()

then:
task.args.set(['a', 'b'])
1 * execSpec.setIgnoreExitValue(true)
1 * execSpec.setEnvironment({ it['a'] == '1' && containsPath(it) })
1 * execSpec.setExecutable('bun')
1 * execSpec.setArgs(['a', 'b'])
}

def "exec bun task (windows)"() {
given:
nodeExtension.resolvedPlatform.set(PlatformHelperKt.parsePlatform("Windows", "x86_64", {}))
def task = project.tasks.create('simple', BunTask)
mockProjectApiHelperExec(task)
task.args.set(['a', 'b'])
task.environment.set(['a': '1'])
task.ignoreExitValue.set(true)
task.workingDir.set(projectDir)
when:
project.evaluate()
task.exec()
then:
task.args.get() == ['a', 'b']
1 * execSpec.setIgnoreExitValue(true)
1 * execSpec.setEnvironment({ it['a'] == '1' && containsPath(it) })
1 * execSpec.setExecutable('bun.cmd')
1 * execSpec.setArgs(['a', 'b'])
}
def "exec bun task (download)"() {
given:
nodeExtension.resolvedPlatform.set(PlatformHelperKt.parsePlatform("Linux", "x86_64", {}))
nodeExtension.download.set(true)
def task = project.tasks.create('simple', PnpmTask)
mockProjectApiHelperExec(task)
when:
project.evaluate()
task.exec()
then:
1 * execSpec.setIgnoreExitValue(false)
}
}

0 comments on commit 4467f28

Please sign in to comment.