Skip to content

Commit

Permalink
refactor: Clean up AssetManagerTest by removing redundant tests and c…
Browse files Browse the repository at this point in the history
…onsolidating configurations

- Removed several test cases that were redundant or overly complex, focusing on essential scenarios for AssetManager's behavior.
- Consolidated Git configuration tests into static final strings for better readability and maintainability.
- Streamlined the setup process for tests, ensuring clarity in the initialization of AssetManager instances.
- Enhanced the clarity of the remaining tests by improving comments and structure, making it easier to understand the purpose of each test case.
  • Loading branch information
edmundmiller committed Dec 13, 2024
1 parent 662efc5 commit 79dec92
Showing 1 changed file with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package nextflow.scm

import spock.lang.IgnoreIf

import nextflow.cli.CmdRun
import nextflow.exception.AbortOperationException
import org.eclipse.jgit.api.Git
Expand All @@ -40,24 +39,16 @@ import java.nio.file.Paths
@IgnoreIf({System.getenv('NXF_SMOKE')})
class AssetManagerTest extends Specification {

// Test configuration for basic Git repository
def "Test configuration for basic Git repository"() {
expect: 'Git config should be properly formatted'
GIT_CONFIG_TEXT == '''
static final String GIT_CONFIG_TEXT = '''
[remote "origin"]
url = https://github.com/nextflow-io/nextflow.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
'''
.stripIndent()
}
'''.stripIndent()

// Test configuration for Git repository with submodules
def "Test configuration for Git repository with submodules"() {
expect: 'Git config with submodules should be properly formatted'
GIT_CONFIG_LONG == '''
static final String GIT_CONFIG_LONG = '''
[core]
repositoryformatversion = 0
filemode = true
Expand All @@ -72,33 +63,25 @@ class AssetManagerTest extends Specification {
merge = refs/heads/master
[submodule "tests"]
url = [email protected]:nextflow-io/tests.git
'''
.stripIndent()
}
'''.stripIndent()

@Rule
TemporaryPath tempDir = new TemporaryPath()

def setup() {
given: 'Initialize AssetManager root directory'
AssetManager.root = tempDir.root.toFile()
}

// Helper method to grab the default branch if set in ~/.gitconfig
String getLocalDefaultBranch() {
given: 'Default branch configuration'
private String getLocalDefaultBranch() {
def defaultBranch = 'master'
def gitconfig = Paths.get(System.getProperty('user.home'),'.gitconfig')

when: 'Git config exists'
if(gitconfig.exists()) {
def config = new Config()
config.fromText(gitconfig.text)
defaultBranch = config.getString('init', null, 'defaultBranch') ?: 'master'
}

then: 'Return the default branch'
return defaultBranch
defaultBranch
}

def "should list available pipeline assets"() {
Expand Down

0 comments on commit 79dec92

Please sign in to comment.