forked from lix-project/lix
Rebecca Turner
2a98ba8b97
The big ones here are `trim-trailing-whitespace` and `end-of-file-fixer`
(which makes sure that every file ends with exactly one newline
character).
Change-Id: Idca73b640883188f068f9903e013cf0d82aa1123
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#include "git.hh"
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace nix {
|
|
|
|
TEST(GitLsRemote, parseSymrefLineWithReference) {
|
|
auto line = "ref: refs/head/main HEAD";
|
|
auto res = git::parseLsRemoteLine(line);
|
|
ASSERT_TRUE(res.has_value());
|
|
ASSERT_EQ(res->kind, git::LsRemoteRefLine::Kind::Symbolic);
|
|
ASSERT_EQ(res->target, "refs/head/main");
|
|
ASSERT_EQ(res->reference, "HEAD");
|
|
}
|
|
|
|
TEST(GitLsRemote, parseSymrefLineWithNoReference) {
|
|
auto line = "ref: refs/head/main";
|
|
auto res = git::parseLsRemoteLine(line);
|
|
ASSERT_TRUE(res.has_value());
|
|
ASSERT_EQ(res->kind, git::LsRemoteRefLine::Kind::Symbolic);
|
|
ASSERT_EQ(res->target, "refs/head/main");
|
|
ASSERT_EQ(res->reference, std::nullopt);
|
|
}
|
|
|
|
TEST(GitLsRemote, parseObjectRefLine) {
|
|
auto line = "abc123 refs/head/main";
|
|
auto res = git::parseLsRemoteLine(line);
|
|
ASSERT_TRUE(res.has_value());
|
|
ASSERT_EQ(res->kind, git::LsRemoteRefLine::Kind::Object);
|
|
ASSERT_EQ(res->target, "abc123");
|
|
ASSERT_EQ(res->reference, "refs/head/main");
|
|
}
|
|
}
|