1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2024-12-03 09:59:00 +02:00

fix and add more tests

This commit is contained in:
Dima 2024-05-07 13:47:47 +03:00
parent a7eca18410
commit 1e8a4ef99c
3 changed files with 28 additions and 4 deletions

View File

@ -38,7 +38,7 @@ class LoadExtensions implements Serializable {
}
}
else {
this.extensionsFiltered = extensions.findAll { extension -> extension.stages.empty || extension.stages.contains("initInfoBase") }
this.extensionsFiltered = extensions.findAll { extension -> extension.stages.length == 0 || extension.stages.contains("initInfoBase") }
}
def env = steps.env()

View File

@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import ru.pulsar.jenkins.library.configuration.ConfigurationReader;
import ru.pulsar.jenkins.library.configuration.InitInfoBaseOptions;
import ru.pulsar.jenkins.library.configuration.JobConfiguration;
import ru.pulsar.jenkins.library.utils.FileUtils;
import ru.pulsar.jenkins.library.utils.TestUtils;
@ -34,20 +35,32 @@ class LoadExtensionsTest {
.thenReturn(new FilePath(new File("/")));
// given
// файл содержит 2 расширения для двух стейджей
// файл содержит 4 расширения для разных стейджей
String config = IOUtils.resourceToString(
"jobConfiguration.json",
StandardCharsets.UTF_8,
this.getClass().getClassLoader()
);
JobConfiguration jobConfiguration = ConfigurationReader.create(config);
LoadExtensions loadExtensions = new LoadExtensions(jobConfiguration, "yaxunit");
// when
LoadExtensions loadExtensions = new LoadExtensions(jobConfiguration);
loadExtensions.run();
// then
assertThat(loadExtensions.getExtensionsFiltered().length).isEqualTo(1);
InitInfoBaseOptions.Extension[] extensions = loadExtensions.getExtensionsFiltered();
assertThat(extensions.length).isEqualTo(2);
assertThat(extensions[0].getName()).isEqualTo("mods");
assertThat(extensions[1].getName()).isEqualTo("mods2");
// when
LoadExtensions loadExtensionsWithStage = new LoadExtensions(jobConfiguration, "yaxunit");
loadExtensionsWithStage.run();
// then
extensions = loadExtensionsWithStage.getExtensionsFiltered();
assertThat(extensions.length).isEqualTo(1);
assertThat(extensions[0].getName()).isEqualTo("YAXUnit");
}
}
}

View File

@ -27,6 +27,17 @@
"initMethod": "fromSource",
"path": "./src/cfe/bdd",
"stages": ["bdd"]
},
{
"name": "mods",
"initMethod": "fromSource",
"path": "./src/cfe/mods"
},
{
"name": "mods2",
"initMethod": "fromSource",
"path": "./src/cfe/mods2",
"stages": ["initInfoBase"]
}
]
},