Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #64 from davalb/config-test
Browse files Browse the repository at this point in the history
adds test for GetAPIUsernameAndPw function
  • Loading branch information
cpacia committed Aug 7, 2016
2 parents 294a9d1 + d69a8ae commit fc385c6
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
31 changes: 31 additions & 0 deletions repo/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package repo

import (
"testing"
)

const testConfigPath = "testdata/config"

func TestGetAPIUsernameAndPw(t *testing.T) {
username, pw, err := GetAPIUsernameAndPw(testConfigPath)
if username != "TestUsername" {
t.Error("Expected TestUsername, got ", username)
}
if pw != "TestPassword" {
t.Error("Expected TestPassword, got ", pw)
}
if err != nil {
t.Error("GetAPIUsernameAndPw threw an unexpected error")
}

username, pw, err = GetAPIUsernameAndPw("testdata/nonexistent")
if username != "" {
t.Error("Expected empty string, got ", username)
}
if pw != "" {
t.Error("Expected empty string, got ", pw)
}
if err == nil {
t.Error("GetAPIUsernameAndPw didn`t throw an error")
}
}
80 changes: 80 additions & 0 deletions repo/testdata/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"API": {
"HTTPHeaders": null
},
"Addresses": {
"API": "",
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip4/0.0.0.0/udp/4001/utp",
"/ip6/::/tcp/4001",
"/ip6/::/udp/4001/utp"
]
},
"Bootstrap": [
"/ip4/107.170.133.32/tcp/4001/ipfs/QmboEn7ycZqb8sXH6wJunWE6d3mdT9iVD7XWDmCcKE9jZ5",
"/ip4/139.59.174.197/tcp/4001/ipfs/QmZbLxbrPfGKjhFPwv9g7PkT5jL5DzQ8mF3iioByWMAprj",
"/ip4/139.59.6.222/tcp/4001/ipfs/QmPZkv392E7VxumGSugQDEpfk6bHxfv271HTdVvdUu5Sod"
],
"Datastore": {
"GCPeriod": "1h",
"NoSync": false,
"Params": null,
"Path": "/Users/uscreen/OpenBazaar2.0/datastore",
"StorageGCWatermark": 90,
"StorageMax": "10GB",
"Type": "leveldb"
},
"Discovery": {
"MDNS": {
"Enabled": false,
"Interval": 10
}
},
"Dropbox-api-token": "",
"Gateway": {
"HTTPHeaders": null,
"PathPrefixes": [],
"RootRedirect": "",
"Writable": false
},
"Identity": {
"PeerID": "",
"PrivKey": ""
},
"Ipns": {
"RecordLifetime": "7d",
"RepublishPeriod": "24h",
"ResolveCacheSize": 128
},
"Mounts": {
"FuseAllowOther": false,
"IPFS": "/ipfs",
"IPNS": "/ipns"
},
"OB-API": {
"CORS": false,
"Enabled": true,
"HTTPHeaders": null,
"Password": "TestPassword",
"Username": "TestUsername"
},
"Resolver": "https://resolver.onename.com/",
"SupernodeRouting": {
"Servers": null
},
"Swarm": {
"AddrFilters": null
},
"Tour": {
"Last": ""
},
"Wallet": {
"FeeAPI": "https://bitcoinfees.21.co/api/v1/fees/recommended",
"HighFeeDefault": 60,
"LowFeeDefault": 20,
"MaxFee": 2000,
"MediumFeeDefault": 40
}
}

0 comments on commit fc385c6

Please sign in to comment.