summaryrefslogtreecommitdiff
path: root/tests/t0403-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/t0403-write.c')
-rw-r--r--tests/t0403-write.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/tests/t0403-write.c b/tests/t0403-write.c
index 8b29b05ea..c8e72da5f 100644
--- a/tests/t0403-write.c
+++ b/tests/t0403-write.c
@@ -1,11 +1,12 @@
#include "test_lib.h"
#include "test_helpers.h"
#include "commit.h"
-#include "person.h"
+#include "signature.h"
#include <git2/odb.h>
#include <git2/commit.h>
#include <git2/revwalk.h>
+#include <git2/signature.h>
static const char *commit_ids[] = {
"a4a7dce85cf63874e984719f4fdd239f5145052f", /* 0 */
@@ -27,7 +28,7 @@ BEGIN_TEST(writenew_test)
git_commit *commit, *parent;
git_tree *tree;
git_oid id;
- const git_person *author, *committer;
+ const git_signature *author, *committer;
/* char hex_oid[41]; */
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
@@ -42,23 +43,33 @@ BEGIN_TEST(writenew_test)
git_commit_add_parent(commit, parent);
/* Set other attributes */
- git_commit_set_committer(commit, COMMITTER_NAME, COMMITTER_EMAIL, 123456789);
- git_commit_set_author(commit, COMMITTER_NAME, COMMITTER_EMAIL, 987654321);
+ committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
+ must_be_true(committer != NULL);
+
+ author = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 987654321, 90);
+ must_be_true(author != NULL);
+
+ git_commit_set_committer(commit, committer);
+ git_commit_set_author(commit, author);
git_commit_set_message(commit, COMMIT_MESSAGE);
+ git_signature_free((git_signature *)committer);
+ git_signature_free((git_signature *)author);
+
/* Check attributes were set correctly */
author = git_commit_author(commit);
must_be_true(author != NULL);
must_be_true(strcmp(author->name, COMMITTER_NAME) == 0);
must_be_true(strcmp(author->email, COMMITTER_EMAIL) == 0);
- must_be_true(author->time == 987654321);
+ must_be_true(author->when.time == 987654321);
+ must_be_true(author->when.offset == 90);
committer = git_commit_committer(commit);
must_be_true(committer != NULL);
must_be_true(strcmp(committer->name, COMMITTER_NAME) == 0);
must_be_true(strcmp(committer->email, COMMITTER_EMAIL) == 0);
- must_be_true(committer->time == 123456789);
- must_be_true(git_commit_time(commit) == 123456789);
+ must_be_true(committer->when.time == 123456789);
+ must_be_true(committer->when.offset == 60);
must_be_true(strcmp(git_commit_message(commit), COMMIT_MESSAGE) == 0);
@@ -74,18 +85,8 @@ BEGIN_TEST(writenew_test)
/* Write to disk */
must_pass(git_object_write((git_object *)commit));
- /* Show new SHA1 */
-/*
- git_oid_fmt(hex_oid, git_commit_id(commit));
- hex_oid[40] = 0;
- printf("Written new commit, SHA1: %s\n", hex_oid);
-*/
-
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
- //git_person_free(&author);
- //git_person_free(&committer);
-
git_repository_free(repo);
END_TEST
@@ -104,12 +105,6 @@ BEGIN_TEST(writeback_test)
message = git_commit_message(commit);
-/*
- git_oid_fmt(hex_oid, git_commit_id(commit));
- hex_oid[40] = 0;
- printf("Old SHA1: %s\n", hex_oid);
-*/
-
git_commit_set_message(commit, "This is a new test message. Cool!\n");
git_oid_mkstr(&id, commit_ids[4]);
@@ -119,12 +114,6 @@ BEGIN_TEST(writeback_test)
must_pass(git_object_write((git_object *)commit));
-/*
- git_oid_fmt(hex_oid, git_commit_id(commit));
- hex_oid[40] = 0;
- printf("New SHA1: %s\n", hex_oid);
-*/
-
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
git_repository_free(repo);