feat: write forgejo local instance URL to json file and port tests read it
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Aravinth Manivannan 2023-09-18 22:15:11 +05:30
parent fa0fb859fe
commit 8551a60d46
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 4 additions and 2 deletions

View file

@ -307,6 +307,7 @@ class Forgejo:
data["login"] = self.username data["login"] = self.username
data["email"] = self.email data["email"] = self.email
data["repo"] = repo data["repo"] = repo
data["forgejo_url"] = self.get_uri("")
content = json.dumps(data) content = json.dumps(data)
f.write(content) f.write(content)
print(f"Wrote access token to {file}") print(f"Wrote access token to {file}")

View file

@ -5,14 +5,15 @@
import Forgejo from "./index"; import Forgejo from "./index";
import authtoken from "../secrets/user1-accesstoken.json"; import authtoken from "../secrets/user1-accesstoken.json";
const forgeoUrl = authtoken["forgejo_url"];
const token = authtoken["sha1"]; const token = authtoken["sha1"];
const username = authtoken["login"]; const username = authtoken["login"];
const repo = authtoken["repo"]; const repo = authtoken["repo"];
const api = new Forgejo("http://localhost:3000", "owner_user"); const api = new Forgejo(forgeoUrl, "owner_user");
api.setTokenAuth(token); api.setTokenAuth(token);
test("use authentication without setting it ", () => { test("use authentication without setting it ", () => {
const api = new Forgejo("http://localhost:3000", "owner_user"); const api = new Forgejo(forgeoUrl, "owner_user");
expect(() => api.getTokenAuth()).toThrow(); expect(() => api.getTokenAuth()).toThrow();
api.setTokenAuth(token); api.setTokenAuth(token);