mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-04-27 19:15:23 +00:00
* Add Sources field to Config and keep track of merged files there. Also print the Sources as a comment in the String() method. Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * Fix tests Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * Fix linter Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * Fix TODO by renaming the toMap function and making it operate on ConfigValues instead of full Config objects (because after all, it wasn't copying the Sources field) Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * [minor] Return ConfigValues interface when erroring out although nobody should consume it since we errored Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * Add check for "Sources" comment to check that these all generate a line: - cmdline - remote config (config_url) - local files Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> --------- Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
47 lines
941 B
Go
47 lines
941 B
Go
package collector_test
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
func TestConfig(t *testing.T) {
|
|
// format.TruncatedDiff = false
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "Config Collector Suite")
|
|
}
|
|
|
|
type ServerCloseFunc func()
|
|
|
|
func startAssetServer(path string) (ServerCloseFunc, int, error) {
|
|
listener, err := net.Listen("tcp", ":0")
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
port := listener.Addr().(*net.TCPAddr).Port
|
|
|
|
ctx, cancelFunc := context.WithCancel(context.Background())
|
|
go func() {
|
|
defer GinkgoRecover()
|
|
err := http.Serve(listener, http.FileServer(http.Dir(path)))
|
|
select {
|
|
case <-ctx.Done(): // We closed it with the CancelFunc, ignore the error
|
|
return
|
|
default: // We didnt' close it, return the error
|
|
Expect(err).ToNot(HaveOccurred())
|
|
}
|
|
}()
|
|
|
|
stopFunc := func() {
|
|
cancelFunc()
|
|
listener.Close()
|
|
}
|
|
|
|
return stopFunc, port, nil
|
|
}
|