#include #include #include #include "common-protocol.hh" #include "common-protocol-impl.hh" #include "build-result.hh" #include "tests/protocol.hh" #include "tests/characterization.hh" namespace nix { const char commonProtoDir[] = "common-protocol"; using CommonProtoTest = ProtoTest; CHARACTERIZATION_TEST( CommonProtoTest, string, "string", (std::tuple { "", "hi", "white rabbit", "大白兔", "oh no \0\0\0 what was that!", })) CHARACTERIZATION_TEST( CommonProtoTest, storePath, "store-path", (std::tuple { StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" }, StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" }, })) CHARACTERIZATION_TEST( CommonProtoTest, contentAddress, "content-address", (std::tuple { ContentAddress { .method = TextIngestionMethod {}, .hash = hashString(HashType::htSHA256, "Derive(...)"), }, ContentAddress { .method = FileIngestionMethod::Flat, .hash = hashString(HashType::htSHA1, "blob blob..."), }, ContentAddress { .method = FileIngestionMethod::Recursive, .hash = hashString(HashType::htSHA256, "(...)"), }, })) CHARACTERIZATION_TEST( CommonProtoTest, drvOutput, "drv-output", (std::tuple { { .drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="), .outputName = "baz", }, DrvOutput { .drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="), .outputName = "quux", }, })) CHARACTERIZATION_TEST( CommonProtoTest, realisation, "realisation", (std::tuple { Realisation { .id = DrvOutput { .drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="), .outputName = "baz", }, .outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" }, .signatures = { "asdf", "qwer" }, }, Realisation { .id = { .drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="), .outputName = "baz", }, .outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" }, .signatures = { "asdf", "qwer" }, .dependentRealisations = { { DrvOutput { .drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="), .outputName = "quux", }, StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" }, }, }, }, })) CHARACTERIZATION_TEST( CommonProtoTest, vector, "vector", (std::tuple, std::vector, std::vector, std::vector>> { { }, { "" }, { "", "foo", "bar" }, { {}, { "" }, { "", "1", "2" } }, })) CHARACTERIZATION_TEST( CommonProtoTest, set, "set", (std::tuple, std::set, std::set, std::set>> { { }, { "" }, { "", "foo", "bar" }, { {}, { "" }, { "", "1", "2" } }, })) CHARACTERIZATION_TEST( CommonProtoTest, optionalStorePath, "optional-store-path", (std::tuple, std::optional> { std::nullopt, std::optional { StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" }, }, })) CHARACTERIZATION_TEST( CommonProtoTest, optionalContentAddress, "optional-content-address", (std::tuple, std::optional> { std::nullopt, std::optional { ContentAddress { .method = FileIngestionMethod::Flat, .hash = hashString(HashType::htSHA1, "blob blob..."), }, }, })) }