Skip to content

Commit 979e90f

Browse files
committed
Make parsing functions public and fix error set test
1 parent a4a0ff0 commit 979e90f

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

zig/src/lib.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub const AuthdogClient = struct {
9191
}
9292
}
9393

94-
fn parseUserInfoResponse(self: *Self, json_str: []const u8) !UserInfoResponse {
94+
pub fn parseUserInfoResponse(self: *Self, json_str: []const u8) !UserInfoResponse {
9595
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
9696
defer _ = gpa.deinit();
9797
const allocator = gpa.allocator();
@@ -116,22 +116,22 @@ pub const AuthdogClient = struct {
116116
};
117117
}
118118

119-
fn parseMeta(self: *Self, obj: std.json.Value) !Meta {
119+
pub fn parseMeta(self: *Self, obj: std.json.Value) !Meta {
120120
_ = self;
121121
return Meta{
122122
.code = @intCast(obj.object.get("code").?.integer),
123123
.message = obj.object.get("message").?.string,
124124
};
125125
}
126126

127-
fn parseSession(self: *Self, obj: std.json.Value) !Session {
127+
pub fn parseSession(self: *Self, obj: std.json.Value) !Session {
128128
_ = self;
129129
return Session{
130130
.remaining_seconds = @intCast(obj.object.get("remainingSeconds").?.integer),
131131
};
132132
}
133133

134-
fn parseNames(self: *Self, obj: std.json.Value) !Names {
134+
pub fn parseNames(self: *Self, obj: std.json.Value) !Names {
135135
_ = self;
136136
return Names{
137137
.id = obj.object.get("id").?.string,
@@ -144,7 +144,7 @@ pub const AuthdogClient = struct {
144144
};
145145
}
146146

147-
fn parsePhoto(self: *Self, obj: std.json.Value) !Photo {
147+
pub fn parsePhoto(self: *Self, obj: std.json.Value) !Photo {
148148
_ = self;
149149
return Photo{
150150
.id = obj.object.get("id").?.string,
@@ -153,7 +153,7 @@ pub const AuthdogClient = struct {
153153
};
154154
}
155155

156-
fn parseEmail(self: *Self, obj: std.json.Value) !Email {
156+
pub fn parseEmail(self: *Self, obj: std.json.Value) !Email {
157157
_ = self;
158158
return Email{
159159
.id = obj.object.get("id").?.string,
@@ -162,7 +162,7 @@ pub const AuthdogClient = struct {
162162
};
163163
}
164164

165-
fn parseVerification(self: *Self, obj: std.json.Value) !Verification {
165+
pub fn parseVerification(self: *Self, obj: std.json.Value) !Verification {
166166
_ = self;
167167
return Verification{
168168
.id = obj.object.get("id").?.string,
@@ -173,7 +173,7 @@ pub const AuthdogClient = struct {
173173
};
174174
}
175175

176-
fn parseUser(self: *Self, obj: std.json.Value) !User {
176+
pub fn parseUser(self: *Self, obj: std.json.Value) !User {
177177
const names_obj = obj.object.get("names") orelse return AuthdogError.ParseError;
178178
const names = try self.parseNames(names_obj);
179179

zig/src/test.zig

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -572,17 +572,7 @@ test "UserInfoResponse deinit" {
572572
}
573573

574574
test "AuthdogError enum values" {
575-
// Test that all error variants exist
576-
const auth_failed = authdog.AuthdogError.AuthenticationFailed;
577-
const api_error = authdog.AuthdogError.ApiError;
578-
const network_error = authdog.AuthdogError.NetworkError;
579-
const parse_error = authdog.AuthdogError.ParseError;
580-
const invalid_token = authdog.AuthdogError.InvalidToken;
581-
582-
// This test mainly ensures the enum compiles correctly
583-
_ = auth_failed;
584-
_ = api_error;
585-
_ = network_error;
586-
_ = parse_error;
587-
_ = invalid_token;
575+
// Test that all error variants exist and can be returned
576+
const testError: authdog.AuthdogError = error.AuthenticationFailed;
577+
_ = testError;
588578
}

0 commit comments

Comments
 (0)