Files
werkator/src/test/kotlin/de/hoennig/werkator/ServerModeApplicationTest.kt
T
mhoennigandClaude Opus 5 35f06ec1ec Rename GitTally to Werkator
`gitTally` is the name of another product in the git space, so the
rename is a precaution; nothing about what the build system does changes.

The name follows one rule: `Werkator` where it is prose, capitalized
where it is a Kotlin type and its file, lowercase everywhere a machine
reads it — the command, packages, paths, configuration keys and values,
the Gitea check context. Environment variables keep their convention and
are uppercase throughout.

Every configuration file is still found under its pre-rename name
(`ConfigFiles`): `.gittally.yml` at the repository root, in a build
worktree and as committed on a branch, `.git/gittally/.gittally.yml` for
the machine layer. The current name wins where both exist, and the old
file is then ignored rather than merged — two files side by side are a
half-done rename, not a layering. Without the fallback an installation
that updated without renaming would not fail: a configuration that is
not found leaves every setting at its default, so it would come up
looking healthy while having forgotten its credentials and its builds.

`docs/werkator-migrationsplan.md` lists what the fallback does not
cover and has to be moved by hand — above all the state directory
`.git/werkator/`, which holds the build history, the control token and
the worktrees, and has no fallback of its own.

`docs/migration-from-legacy.md` is deleted with this: it mapped the
legacy script's environment variables, and every host it addressed has
long since moved to the YAML configuration.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-30 19:39:55 +02:00

52 lines
1.8 KiB
Kotlin

package de.hoennig.werkator
import com.ninjasquad.springmockk.MockkBean
import de.hoennig.werkator.metrics.SystemMetricsCollector
import de.hoennig.werkator.watcher.Watcher
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.booleans.shouldBeTrue
import io.mockk.verify
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.server.LocalServerPort
import org.springframework.http.MediaType
import org.springframework.test.context.ActiveProfiles
import org.springframework.web.client.RestClient
/**
* Proves the `server` profile boots a real web server and starts the watcher and
* the metrics collector. Both are mocked so the test never fetches origin,
* enqueues builds, or walks the repository for its size.
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("server")
class ServerModeApplicationTest : FunSpec() {
@MockkBean(relaxUnitFun = true)
lateinit var watcher: Watcher
@MockkBean(relaxUnitFun = true)
lateinit var metricsCollector: SystemMetricsCollector
@LocalServerPort
var port: Int = 0
init {
test("the server profile answers the JSON API and starts the watcher") {
val response =
RestClient
.create("http://localhost:$port")
.get()
.uri("/api/builds/latest")
.retrieve()
.toEntity(String::class.java)
response.statusCode.is2xxSuccessful.shouldBeTrue()
response.headers.contentType!!
.isCompatibleWith(MediaType.APPLICATION_JSON)
.shouldBeTrue()
verify { watcher.start(any()) }
verify { metricsCollector.start() }
}
}
}