1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 10:11:47 +02:00

fix: linting

This commit is contained in:
Thomas Bereknyei 2025-02-13 13:04:38 -05:00
parent 753f00c351
commit 3b5514e0c6

View file

@ -14,86 +14,87 @@ class AccessKeysTest : public ::testing::Test
protected: protected:
public: public:
void SetUp() override { void SetUp() override
{
experimentalFeatureSettings.experimentalFeatures.get().insert(Xp::Flakes); experimentalFeatureSettings.experimentalFeatures.get().insert(Xp::Flakes);
} }
void TearDown() override { } void TearDown() override {}
}; };
TEST_F(AccessKeysTest, singleOrgGitHub) TEST_F(AccessKeysTest, singleOrgGitHub)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"github.com/a","token"}); fetchSettings.accessTokens.get().insert({"github.com/a", "token"});
auto i = Input::fromURL(fetchSettings, "github:a/b"); auto i = Input::fromURL(fetchSettings, "github:a/b");
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b"); auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b");
ASSERT_EQ(token,"token"); ASSERT_EQ(token, "token");
} }
TEST_F(AccessKeysTest, nonMatches) TEST_F(AccessKeysTest, nonMatches)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"github.com","token"}); fetchSettings.accessTokens.get().insert({"github.com", "token"});
auto i = Input::fromURL(fetchSettings, "gitlab:github.com/evil"); auto i = Input::fromURL(fetchSettings, "gitlab:github.com/evil");
auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/github.com/evil"); auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/github.com/evil");
ASSERT_EQ(token,std::nullopt); ASSERT_EQ(token, std::nullopt);
} }
TEST_F(AccessKeysTest, noPartialMatches) TEST_F(AccessKeysTest, noPartialMatches)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"github.com/partial","token"}); fetchSettings.accessTokens.get().insert({"github.com/partial", "token"});
auto i = Input::fromURL(fetchSettings, "github:partial-match/repo"); auto i = Input::fromURL(fetchSettings, "github:partial-match/repo");
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/partial-match"); auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/partial-match");
ASSERT_EQ(token,std::nullopt); ASSERT_EQ(token, std::nullopt);
} }
TEST_F(AccessKeysTest, repoGitHub) TEST_F(AccessKeysTest, repoGitHub)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"github.com","token"}); fetchSettings.accessTokens.get().insert({"github.com", "token"});
fetchSettings.accessTokens.get().insert({"github.com/a/b","another_token"}); fetchSettings.accessTokens.get().insert({"github.com/a/b", "another_token"});
fetchSettings.accessTokens.get().insert({"github.com/a/c","yet_another_token"}); fetchSettings.accessTokens.get().insert({"github.com/a/c", "yet_another_token"});
auto i = Input::fromURL(fetchSettings, "github:a/a"); auto i = Input::fromURL(fetchSettings, "github:a/a");
auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/a"); auto token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/a");
ASSERT_EQ(token,"token"); ASSERT_EQ(token, "token");
token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b"); token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/b");
ASSERT_EQ(token,"another_token"); ASSERT_EQ(token, "another_token");
token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/c"); token = i.scheme->getAccessToken(fetchSettings, "github.com", "github.com/a/c");
ASSERT_EQ(token,"yet_another_token"); ASSERT_EQ(token, "yet_another_token");
} }
TEST_F(AccessKeysTest, multipleGitLab) TEST_F(AccessKeysTest, multipleGitLab)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"gitlab.com","token"}); fetchSettings.accessTokens.get().insert({"gitlab.com", "token"});
fetchSettings.accessTokens.get().insert({"gitlab.com/a/b","another_token"}); fetchSettings.accessTokens.get().insert({"gitlab.com/a/b", "another_token"});
auto i = Input::fromURL(fetchSettings, "gitlab:a/b"); auto i = Input::fromURL(fetchSettings, "gitlab:a/b");
auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/b"); auto token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/b");
ASSERT_EQ(token,"another_token"); ASSERT_EQ(token, "another_token");
token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/c"); token = i.scheme->getAccessToken(fetchSettings, "gitlab.com", "gitlab.com/a/c");
ASSERT_EQ(token,"token"); ASSERT_EQ(token, "token");
} }
TEST_F(AccessKeysTest, multipleSourceHut) TEST_F(AccessKeysTest, multipleSourceHut)
{ {
fetchers::Settings fetchSettings = fetchers::Settings{}; fetchers::Settings fetchSettings = fetchers::Settings{};
fetchSettings.accessTokens.get().insert({"git.sr.ht","token"}); fetchSettings.accessTokens.get().insert({"git.sr.ht", "token"});
fetchSettings.accessTokens.get().insert({"git.sr.ht/~a/b","another_token"}); fetchSettings.accessTokens.get().insert({"git.sr.ht/~a/b", "another_token"});
auto i = Input::fromURL(fetchSettings, "sourcehut:a/b"); auto i = Input::fromURL(fetchSettings, "sourcehut:a/b");
auto token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/b"); auto token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/b");
ASSERT_EQ(token,"another_token"); ASSERT_EQ(token, "another_token");
token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/c"); token = i.scheme->getAccessToken(fetchSettings, "git.sr.ht", "git.sr.ht/~a/c");
ASSERT_EQ(token,"token"); ASSERT_EQ(token, "token");
} }
} }