Skip to content

Commit

Permalink
Setup reporting api key before running test
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Nov 2, 2023
1 parent 25d76b4 commit fad6d98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/androidTest/java/de/blau/android/FeedbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import androidx.test.uiautomator.UiDevice;
import de.blau.android.prefs.AdvancedPrefDatabase;
import de.blau.android.prefs.Preferences;
import de.blau.android.resources.KeyDatabaseHelper;
import de.blau.android.resources.KeyDatabaseHelper.EntryType;
import okhttp3.HttpUrl;

@RunWith(AndroidJUnit4.class)
Expand All @@ -46,6 +48,7 @@ public void setup() {
device = UiDevice.getInstance(instrumentation);
context = instrumentation.getTargetContext();
main = mActivityRule.getActivity();
KeyDatabaseHelper.replaceOrDeleteKey(new KeyDatabaseHelper(main).getWritableDatabase(), Feedback.VESPUCCI_REPORTER_ENTRY, EntryType.API_KEY, "123", false, false, null, null);;
mockServer = new MockWebServerPlus();
HttpUrl mockBaseUrl = mockServer.server().url("/api/0.6/");
prefDB = new AdvancedPrefDatabase(context);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/de/blau/android/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public class Feedback extends IssueReporterActivity implements ActivityResultHan

private static final String DEBUG_TAG = "Feedback";

private static final String REPO_USER_KEY = "repo_user";
private static final String REPO_NAME_KEY = "repo_name";
private static final String GITHUB_API_KEY = "github_api_key";
static final String VESPUCCI_REPORTER_ENTRY = "VESPUCCI_REPORTER";
private static final String REPO_USER_KEY = "repo_user";
private static final String REPO_NAME_KEY = "repo_name";
private static final String GITHUB_API_KEY = "github_api_key";

private static final String EMPTY_BUG_REPORT = "bug_report_empty.md";

Expand Down Expand Up @@ -88,7 +89,7 @@ public static void start(@NonNull Context context, boolean useUrl) {
*/
public static void start(@NonNull Context context, @NonNull String repoUser, @NonNull String repoName, boolean useUrl) {
try (KeyDatabaseHelper keys = new KeyDatabaseHelper(context); SQLiteDatabase db = keys.getReadableDatabase()) {
String apiKey = KeyDatabaseHelper.getKey(db, "VESPUCCI_REPORTER", EntryType.API_KEY);
String apiKey = KeyDatabaseHelper.getKey(db, VESPUCCI_REPORTER_ENTRY, EntryType.API_KEY);
if (useUrl || Util.isPackageInstalled(Github.APP, context.getPackageManager()) || Util.isEmpty(apiKey)) {
reportViaUrl(context, repoUser, repoName);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
* @param add1 1st additional value to store
* @param add2 2nd additional value to store
*/
static void replaceOrDeleteKey(@NonNull SQLiteDatabase db, @NonNull String name, @NonNull EntryType type, @Nullable String key, boolean custom,
public static void replaceOrDeleteKey(@NonNull SQLiteDatabase db, @NonNull String name, @NonNull EntryType type, @Nullable String key, boolean custom,
boolean overwrite, @Nullable String add1, @Nullable String add2) {
if ("".equals(key) && overwrite) {
Log.i(DEBUG_TAG, "Deleting key " + name);
Expand Down

0 comments on commit fad6d98

Please sign in to comment.