Remove diag dumps

remove_diag_dumps
Rick Carlino 2020-02-04 13:42:40 -06:00
parent 1934e4ba7c
commit 0b4ea1e385
39 changed files with 32 additions and 413 deletions

View File

@ -1,26 +0,0 @@
module Api
class DiagnosticDumpsController < Api::AbstractController
def index
render json: diagnostic_dumps
end
def create
mutate DiagnosticDumps::Create.run(raw_json, device: current_device)
end
def destroy
diagnostic_dump.destroy!
render json: ""
end
private
def diagnostic_dumps
current_device.diagnostic_dumps
end
def diagnostic_dump
@diagnostic_dump ||= diagnostic_dumps.find(params[:id])
end
end
end

View File

@ -16,7 +16,7 @@ class Device < ApplicationRecord
images logs peripherals pin_bindings plant_templates
points point_groups regimens saved_gardens
sensor_readings sensors sequences token_issuances tools
webcam_feeds diagnostic_dumps fragments)
webcam_feeds fragments)
PLURAL_RESOURCES.map { |resources| has_many resources, dependent: :destroy }

View File

@ -1,3 +0,0 @@
class DiagnosticDump < ApplicationRecord
belongs_to :device
end

View File

@ -1,25 +0,0 @@
module DiagnosticDumps
class Create < Mutations::Command
required do
model :device, class: Device
string :fbos_version
string :fbos_commit
string :firmware_commit
string :network_interface
string :fbos_dmesg_dump
string :firmware_state
end
def execute
DiagnosticDump
.create!(device: device,
ticket_identifier: rand(36**5).to_s(36),
fbos_version: fbos_version,
fbos_commit: fbos_commit,
firmware_commit: firmware_commit,
network_interface: network_interface,
fbos_dmesg_dump: fbos_dmesg_dump,
firmware_state: firmware_state,)
end
end
end

View File

@ -1,3 +0,0 @@
module DiagnosticDumps
Destroy = CreateDestroyer.run!(resource: DiagnosticDump)
end

View File

@ -1,5 +0,0 @@
class DiagnosticDumpSerializer < ApplicationSerializer
attributes :device_id, :ticket_identifier, :fbos_commit, :fbos_version,
:firmware_commit, :firmware_state, :network_interface,
:fbos_dmesg_dump
end

View File

@ -8,7 +8,6 @@ FarmBot::Application.routes.draw do
# Standard API Resources:
{
alerts: [:create, :destroy, :index],
diagnostic_dumps: [:create, :destroy, :index],
farm_events: [:create, :destroy, :index, :show, :update],
farmware_envs: [:create, :destroy, :index, :show, :update],
first_party_farmwares: [:show, :index],

View File

@ -0,0 +1,20 @@
class DropDiagnosticDumps < ActiveRecord::Migration[6.0]
def change
drop_table :diagnostic_dumps do |t|
t.references :device, foreign_key: true, null: false
t.string :fbos_commit, null: false
t.string :fbos_version, null: false
t.string :firmware_commit, null: false
t.string :firmware_hardware, limit: 12
t.string :firmware_state, null: false
t.string :firmware_version, limit: 12
t.string :network_interface, null: false
t.string :soc_temp, limit: 12
t.string :sync_status, limit: 12
t.string :ticket_identifier, null: false, unique: true
t.string :wifi_level, limit: 12
t.text :fbos_dmesg_dump, null: false
t.timestamps
end
end
end

View File

@ -301,49 +301,6 @@ CREATE SEQUENCE public.devices_id_seq
ALTER SEQUENCE public.devices_id_seq OWNED BY public.devices.id;
--
-- Name: diagnostic_dumps; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.diagnostic_dumps (
id bigint NOT NULL,
device_id bigint NOT NULL,
ticket_identifier character varying NOT NULL,
fbos_commit character varying NOT NULL,
fbos_version character varying NOT NULL,
firmware_commit character varying NOT NULL,
firmware_state character varying NOT NULL,
network_interface character varying NOT NULL,
fbos_dmesg_dump text NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
sync_status character varying(12),
wifi_level character varying(12),
soc_temp character varying(12),
firmware_hardware character varying(12),
firmware_version character varying(12)
);
--
-- Name: diagnostic_dumps_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.diagnostic_dumps_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: diagnostic_dumps_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.diagnostic_dumps_id_seq OWNED BY public.diagnostic_dumps.id;
--
-- Name: edge_nodes; Type: TABLE; Schema: public; Owner: -
--
@ -1877,13 +1834,6 @@ ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public
ALTER TABLE ONLY public.devices ALTER COLUMN id SET DEFAULT nextval('public.devices_id_seq'::regclass);
--
-- Name: diagnostic_dumps id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.diagnostic_dumps ALTER COLUMN id SET DEFAULT nextval('public.diagnostic_dumps_id_seq'::regclass);
--
-- Name: edge_nodes id; Type: DEFAULT; Schema: public; Owner: -
--
@ -2193,14 +2143,6 @@ ALTER TABLE ONLY public.devices
ADD CONSTRAINT devices_pkey PRIMARY KEY (id);
--
-- Name: diagnostic_dumps diagnostic_dumps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.diagnostic_dumps
ADD CONSTRAINT diagnostic_dumps_pkey PRIMARY KEY (id);
--
-- Name: edge_nodes edge_nodes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -2552,13 +2494,6 @@ CREATE INDEX index_devices_on_mounted_tool_id ON public.devices USING btree (mou
CREATE INDEX index_devices_on_timezone ON public.devices USING btree (timezone);
--
-- Name: index_diagnostic_dumps_on_device_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_diagnostic_dumps_on_device_id ON public.diagnostic_dumps USING btree (device_id);
--
-- Name: index_edge_nodes_on_kind_and_value; Type: INDEX; Schema: public; Owner: -
--
@ -3150,14 +3085,6 @@ ALTER TABLE ONLY public.active_storage_attachments
ADD CONSTRAINT fk_rails_c3b3935057 FOREIGN KEY (blob_id) REFERENCES public.active_storage_blobs(id);
--
-- Name: diagnostic_dumps fk_rails_c5df7fdc83; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.diagnostic_dumps
ADD CONSTRAINT fk_rails_c5df7fdc83 FOREIGN KEY (device_id) REFERENCES public.devices(id);
--
-- Name: farmware_installations fk_rails_c72f38683f; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -3448,6 +3375,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20191203163621'),
('20191219212755'),
('20191220010646'),
('20200116140201');
('20200116140201'),
('20200204192005');

View File

@ -7,7 +7,6 @@ export const panelState = (): ControlPanelState => {
encoders_and_endstops: false,
danger_zone: false,
power_and_reset: false,
pin_guard: false,
diagnostic_dumps: false
pin_guard: false
};
};

View File

@ -10,7 +10,6 @@ export const bot: Everything["bot"] = {
"danger_zone": false,
"power_and_reset": false,
"pin_guard": false,
"diagnostic_dumps": false
},
"hardware": {
"gpio_registry": {},

View File

@ -1,7 +1,6 @@
import { Everything } from "../../interfaces";
import { buildResourceIndex } from "../resource_index_builder";
import {
TaggedDiagnosticDump,
TaggedFarmEvent,
TaggedFbosConfig,
TaggedFirmwareConfig,
@ -159,23 +158,6 @@ export function fakePlant(): TaggedPlantPointer {
});
}
export function fakeDiagnosticDump(): TaggedDiagnosticDump {
const string = "----PLACEHOLDER DIAG STUFF ---";
return fakeResource("DiagnosticDump", {
id: idCounter++,
device_id: idCounter++,
ticket_identifier: string,
fbos_commit: string,
fbos_version: string,
firmware_commit: string,
firmware_state: string,
network_interface: string,
fbos_dmesg_dump: string,
created_at: "2018-01-11T20:20:38.362Z",
updated_at: "2018-01-11T20:20:38.362Z",
});
}
export function fakePoint(): TaggedGenericPointer {
return fakeResource("Point", {
id: idCounter++,

View File

@ -375,7 +375,6 @@ const KIND_PRIORITY: ResourceLookupTable = {
Regimen: 3,
PinBinding: 3,
FarmEvent: 4,
DiagnosticDump: 4,
Image: 4,
Log: 4,
WebcamFeed: 4,

View File

@ -13,7 +13,6 @@ describe("API", () => {
[API.current.sensorReadingPath, BASE + "/api/sensor_readings"],
[API.current.farmwareEnvPath, BASE + "/api/farmware_envs/"],
[API.current.plantTemplatePath, BASE + "/api/plant_templates/"],
[API.current.diagnosticDumpsPath, BASE + "/api/diagnostic_dumps/"],
[API.current.farmwareInstallationPath, BASE + "/api/farmware_installations/"],
[API.current.globalBulletinPath, BASE + "/api/global_bulletins/"],
[API.current.accountSeedPath, BASE + "/api/device/seed"],

View File

@ -154,8 +154,6 @@ export class API {
get exportDataPath() { return `${this.baseUrl}/api/export_data`; }
/** /api/plant_templates/:id */
get plantTemplatePath() { return `${this.baseUrl}/api/plant_templates/`; }
/** /api/diagnostic_dumps/:id */
get diagnosticDumpsPath() { return `${this.baseUrl}/api/diagnostic_dumps/`; }
/** /api/farmware_installations/:id */
get farmwareInstallationPath() {
return `${this.baseUrl}/api/farmware_installations/`;

View File

@ -260,7 +260,6 @@ export function urlFor(tag: ResourceName) {
const OPTIONS: Partial<Record<ResourceName, string>> = {
Alert: API.current.alertPath,
Device: API.current.devicePath,
DiagnosticDump: API.current.diagnosticDumpsPath,
FarmEvent: API.current.farmEventsPath,
FarmwareEnv: API.current.farmwareEnvPath,
FarmwareInstallation: API.current.farmwareInstallationPath,

View File

@ -3,7 +3,6 @@ import { startTracking } from "../connectivity/data_consistency";
import { unpackUUID } from "../util";
const BLACKLIST: ResourceName[] = [
"DiagnosticDump",
"FbosConfig",
"FirmwareConfig",
"Image",

View File

@ -13,8 +13,7 @@ const mockDeviceDefault: DeepPartial<Farmbot> = {
readPin: jest.fn(() => Promise.resolve()),
home: jest.fn(() => Promise.resolve()),
sync: jest.fn(() => Promise.resolve()),
readStatus: jest.fn(() => Promise.resolve()),
dumpInfo: jest.fn(() => Promise.resolve())
readStatus: jest.fn(() => Promise.resolve())
};
const mockDevice = {
@ -213,13 +212,6 @@ describe("MCUFactoryReset()", function () {
});
});
describe("requestDiagnostic", () => {
it("requests that FBOS build a diagnostic report", () => {
actions.requestDiagnostic();
expect(mockDevice.current.dumpInfo).toHaveBeenCalled();
});
});
describe("settingToggle()", () => {
it("toggles mcu param via FirmwareConfig", () => {
const sourceSetting = () => ({ value: 1, consistent: true });

View File

@ -53,7 +53,7 @@ describe("botReducer", () => {
});
const bulkToggable =
omit(state.controlPanelState, "power_and_reset", "diagnostic_dumps");
omit(state.controlPanelState, "power_and_reset");
values(bulkToggable).map(value => {
expect(value).toBeTruthy();
});

View File

@ -168,11 +168,6 @@ export function execSequence(
}
}
export function requestDiagnostic() {
const noun = t("Diagnostic Request");
return getDevice().dumpInfo().then(commandOK(noun), commandErr(noun));
}
const tagNameToVersionString = (tagName: string): string =>
tagName.toLowerCase().replace("v", "");

View File

@ -1,23 +0,0 @@
jest.mock("../../../api/crud", () => {
return { destroy: jest.fn() };
});
import * as React from "react";
import { mount } from "enzyme";
import { DiagnosticDumpRow } from "../diagnostic_dump_row";
import {
fakeDiagnosticDump
} from "../../../__test_support__/fake_state/resources";
import { destroy } from "../../../api/crud";
describe("<DiagnosticDumpRow/>", () => {
it("renders a single diagnostic dump", () => {
const dispatch = jest.fn();
const diag = fakeDiagnosticDump();
diag.body.ticket_identifier = "0000";
const el = mount(<DiagnosticDumpRow dispatch={dispatch} diag={diag} />);
expect(el.text()).toContain("0000");
el.find("button.red").first().simulate("click");
expect(destroy).toHaveBeenCalledWith(diag.uuid);
});
});

View File

@ -35,7 +35,6 @@ describe("<FarmbotOsSettings />", () => {
ota_hour: 3,
tz_offset_hrs: 0
}),
diagnostics: [],
dispatch: jest.fn(),
bot,
alerts: [],

View File

@ -1,19 +0,0 @@
import * as React from "react";
import { render } from "enzyme";
import { SendDiagnosticReport, DiagReportProps } from "../send_diagnostic_report";
import { fakeDiagnosticDump } from "../../../__test_support__/fake_state/resources";
describe("<SendDiagnosticReport/>", () => {
const fakeProps = (): DiagReportProps => ({
dispatch: jest.fn(),
diagnostics: [fakeDiagnosticDump()],
expanded: true,
botOnline: true,
});
it("renders", () => {
const p = fakeProps();
const wrapper = render(<SendDiagnosticReport {...p} />);
expect(wrapper.text()).toContain("DIAGNOSTIC CHECK");
});
});

View File

@ -1,37 +0,0 @@
import * as React from "react";
import { Row, Col } from "../../ui";
import { TaggedDiagnosticDump } from "farmbot";
import { destroy } from "../../api/crud";
import { ago } from "../connectivity/status_checks";
import { t } from "../../i18next_wrapper";
export interface Props {
diag: TaggedDiagnosticDump;
dispatch: Function;
}
export class DiagnosticDumpRow extends React.Component<Props, {}> {
get ticket() { return this.props.diag.body.ticket_identifier; }
get age() { return ago(this.props.diag.body.created_at); }
destroy = () => this.props.dispatch(destroy(this.props.diag.uuid));
render() {
return <Row>
<Col xsOffset={3} xs={8}>
{t("Report {{ticket}} (Saved {{age}})", {
ticket: this.ticket, age: this.age
})}
</Col>
<Col xs={1}>
<button
className="red fb-button del-button"
title={t("Delete")}
onClick={this.destroy}>
<i className="fa fa-times" />
</button>
</Col>
</Row>;
}
}

View File

@ -14,7 +14,6 @@ import { FarmbotOsRow } from "./fbos_settings/farmbot_os_row";
import { AutoUpdateRow } from "./fbos_settings/auto_update_row";
import { AutoSyncRow } from "./fbos_settings/auto_sync_row";
import { PowerAndReset } from "./fbos_settings/power_and_reset";
import { SendDiagnosticReport } from "./send_diagnostic_report";
import { BootSequenceSelector } from "./fbos_settings/boot_sequence_selector";
export enum ColWidth {
@ -164,11 +163,6 @@ export class FarmbotOsSettings
sourceFbosConfig={sourceFbosConfig}
shouldDisplay={this.props.shouldDisplay}
botOnline={botOnline} />
<SendDiagnosticReport
diagnostics={this.props.diagnostics}
expanded={this.props.bot.controlPanelState.diagnostic_dumps}
botOnline={isBotOnline(sync_status, botToMqttStatus)}
dispatch={this.props.dispatch} />
</MustBeOnline>
</WidgetBody>
</form>

View File

@ -1,59 +0,0 @@
import * as React from "react";
import { Row, Col } from "../../ui";
import { ColWidth } from "./farmbot_os_settings";
import { Collapse } from "@blueprintjs/core";
import { Header } from "./hardware_settings/header";
import { Feature } from "../interfaces";
import { TaggedDiagnosticDump } from "farmbot";
import { DiagnosticDumpRow } from "./diagnostic_dump_row";
import { requestDiagnostic } from "../actions";
import { Content } from "../../constants";
import { t } from "../../i18next_wrapper";
export interface DiagReportProps {
dispatch: Function;
expanded: boolean;
diagnostics: TaggedDiagnosticDump[];
botOnline: boolean;
}
export class SendDiagnosticReport extends React.Component<DiagReportProps, {}> {
render() {
return <section>
<div style={{ fontSize: "1px" }}>
<Header
expanded={this.props.expanded}
title={t("Diagnostic Reports")}
name={Feature.diagnostic_dumps}
dispatch={this.props.dispatch} />
</div>
<Collapse isOpen={this.props.expanded}>
<Row>
<Col xs={ColWidth.label}>
<label>
{t("DIAGNOSTIC CHECK")}
</label>
</Col>
<Col xs={6}>
<p>{t(Content.DIAGNOSTIC_CHECK)}</p>
</Col>
<Col xs={3}>
<button
className="fb-button yellow"
disabled={!this.props.botOnline}
onClick={requestDiagnostic}>
{t("Record Diagnostic")}
</button>
</Col>
</Row>
<hr />
{this.props.diagnostics.map(d => {
return <DiagnosticDumpRow
key={d.uuid}
diag={d}
dispatch={this.props.dispatch} />;
})}
</Collapse>
</section>;
}
}

View File

@ -6,7 +6,6 @@ import { Page, Col, Row } from "../ui/index";
import { mapStateToProps } from "./state_to_props";
import { Props } from "./interfaces";
import { PinBindings } from "./pin_bindings/pin_bindings";
import { selectAllDiagnosticDumps } from "../resources/selectors";
import { getStatus } from "../connectivity/reducer_support";
import { isFwHardwareValue } from "./components/firmware_hardware_support";
@ -24,7 +23,6 @@ export class RawDevices extends React.Component<Props, {}> {
<Row>
<Col xs={12} sm={6}>
<FarmbotOsSettings
diagnostics={selectAllDiagnosticDumps(this.props.resources)}
deviceAccount={this.props.deviceAccount}
dispatch={this.props.dispatch}
alerts={this.props.alerts}

View File

@ -6,7 +6,6 @@ import {
TaggedPeripheral,
TaggedDevice,
TaggedSensor,
TaggedDiagnosticDump,
TaggedFarmwareInstallation,
JobProgress,
FirmwareHardware,
@ -74,7 +73,6 @@ export enum Feature {
backscheduled_regimens = "backscheduled_regimens",
boot_sequence = "boot_sequence",
change_ownership = "change_ownership",
diagnostic_dumps = "diagnostic_dumps",
endstop_invert = "endstop_invert",
express_k10 = "express_k10",
farmduino_k14 = "farmduino_k14",
@ -164,7 +162,6 @@ export type UserEnv = Record<string, string | undefined>;
export interface FarmbotOsProps {
bot: BotState;
alerts: Alert[];
diagnostics: TaggedDiagnosticDump[];
deviceAccount: TaggedDevice;
botToMqttStatus: NetworkState;
botToMqttLastSeen: number;
@ -251,5 +248,4 @@ export interface ControlPanelState {
danger_zone: boolean;
power_and_reset: boolean;
pin_guard: boolean;
diagnostic_dumps: boolean;
}

View File

@ -25,7 +25,6 @@ export const specialActionLabelLookup: { [x: string]: string } = {
[PinBindingSpecialAction.power_off]: t("Shutdown"),
[PinBindingSpecialAction.reboot]: t("Reboot"),
[PinBindingSpecialAction.sync]: t("Sync"),
[PinBindingSpecialAction.dump_info]: t("Diagnostic Report"),
[PinBindingSpecialAction.read_status]: t("Read Status"),
[PinBindingSpecialAction.take_photo]: t("Take Photo"),
"": t("None")

View File

@ -30,8 +30,7 @@ export const initialState = (): BotState => ({
encoders_and_endstops: false,
danger_zone: false,
power_and_reset: false,
pin_guard: false,
diagnostic_dumps: false
pin_guard: false
},
hardware: {
gpio_registry: {},

View File

@ -65,7 +65,7 @@ describe("resource reducer", () => {
});
const TEST_RESOURCE_NAMES: TaggedResource["kind"][] = ["Crop", "Device",
"DiagnosticDump", "FarmEvent", "FarmwareInstallation", "FbosConfig",
"FarmEvent", "FarmwareInstallation", "FbosConfig",
"FirmwareConfig", "Log", "Peripheral", "PinBinding", "PlantTemplate",
"Point", "Regimen", "SavedGarden", "Sensor"];

View File

@ -44,7 +44,6 @@ export const emptyState = (): RestResources => {
Alert: {},
Crop: {},
Device: {},
DiagnosticDump: {},
FarmEvent: {},
FarmwareEnv: {},
FarmwareInstallation: {},

View File

@ -14,7 +14,6 @@ import {
TaggedSensor,
TaggedPeripheral,
TaggedPinBinding,
TaggedDiagnosticDump,
TaggedSensorReading,
TaggedSavedGarden,
TaggedPlantTemplate,
@ -82,8 +81,6 @@ export const selectAllPointGroups =
export const selectAllActivePoints = (input: ResourceIndex) =>
selectAllPoints(input).filter(x => !x.body.discarded_at);
export const selectAllDiagnosticDumps =
(i: ResourceIndex) => findAll<TaggedDiagnosticDump>(i, "DiagnosticDump");
export const selectAllFarmwareEnvs =
(i: ResourceIndex) => findAll<TaggedFarmwareEnv>(i, "FarmwareEnv");
export const selectAllFarmwareInstallations = (i: ResourceIndex) =>

View File

@ -203,10 +203,6 @@ describe("renderCeleryNode()", () => {
node: { kind: "sync", args: {} },
expected: ""
},
{
node: { kind: "dump_info", args: {} },
expected: ""
},
{
node: { kind: "power_off", args: {} },
expected: ""

View File

@ -90,7 +90,6 @@ export async function fetchSyncData(dispatch: Function) {
]),
4: () => Promise.all<{}>([
get("FarmEvent", API.current.farmEventsPath),
get("DiagnosticDump", API.current.diagnosticDumpsPath),
get("Image", API.current.imagesPath),
get("Log", API.current.filteredLogsPath),
get("WebcamFeed", API.current.webcamFeedPath)

View File

@ -45,7 +45,7 @@
"coveralls": "3.0.9",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.2",
"farmbot": "9.0.1-rc1",
"farmbot": "9.0.2",
"i18next": "19.0.3",
"install": "0.13.0",
"lodash": "4.17.15",
@ -69,7 +69,6 @@
"redux": "4.0.5",
"redux-immutable-state-invariant": "2.1.0",
"redux-thunk": "2.3.0",
"sass": "1.25.0",
"sass-lint": "1.13.1",
"takeme": "0.11.3",
"ts-jest": "25.0.0",
@ -81,9 +80,10 @@
"devDependencies": {
"jest": "25.1.0",
"jest-cli": "25.1.0",
"jest-skipped-reporter": "0.0.5",
"jest-junit": "10.0.0",
"jest-skipped-reporter": "0.0.5",
"jshint": "2.11.0",
"madge": "3.6.0"
"madge": "3.6.0",
"sass": "1.25.0"
}
}

View File

@ -15,7 +15,6 @@ describe Api::DevicesController do
it "provides timestamps of updates, plus current time" do
sign_in user
FactoryBot.create(:diagnostic_dump, device: device)
FactoryBot.create(:farm_event, device: device)
FactoryBot.create(:farmware_env, device: device)
FactoryBot.create(:farmware_installation, device: device)

View File

@ -1,52 +0,0 @@
require 'spec_helper'
describe Api::DiagnosticDumpsController do
let(:device) { FactoryBot.create(:device) }
let(:user) { FactoryBot.create(:user, device: device) }
include Devise::Test::ControllerHelpers
it 'lists all diagnostics' do
sign_in user
DiagnosticDump.destroy_all
farmware_env = FactoryBot.create_list(:diagnostic_dump, 3, device: device)
get :index
expect(json.length).to eq(3)
expect(json.pluck(:device_id).uniq).to eq([user.device.id])
end
it 'creates a dump' do # Blinky test 7-AUG-18 RC
sign_in user
DiagnosticDump.destroy_all
b4 = DiagnosticDump.count
input = {
fbos_version: "123_fbos_version",
fbos_commit: "123_fbos_commit",
firmware_commit: "123_firmware_commit",
network_interface: "123_network_interface",
fbos_dmesg_dump: "123_fbos_dmesg_dump",
firmware_state: "123_firmware_state",
}
post :create, body: input.to_json
expect(response.status).to eq(200)
expect(DiagnosticDump.count).to be > b4
expect(DiagnosticDump.last.device).to eq(device)
expect(json[:fbos_version]).to eq("123_fbos_version")
expect(json[:fbos_commit]).to eq("123_fbos_commit")
expect(json[:firmware_commit]).to eq("123_firmware_commit")
expect(json[:network_interface]).to eq("123_network_interface")
expect(json[:fbos_dmesg_dump]).to eq("123_fbos_dmesg_dump")
expect(json[:firmware_state]).to eq("123_firmware_state")
expect(json[:ticket_identifier].length).to be >= 4
end
it 'deletes' do
sign_in user
# DiagnosticDump.destroy_all
farmware_env = FactoryBot.create(:diagnostic_dump, device: device)
id = farmware_env.id
delete :destroy, params: { id: farmware_env.id }
expect(response.status).to eq(200)
expect(DiagnosticDump.exists?(id)).to be false
end
end

View File

@ -1,12 +0,0 @@
FactoryBot.define do
factory :diagnostic_dump do
device
fbos_version { "123_fbos_version" }
fbos_commit { "123_fbos_commit" }
firmware_commit { "123_firmware_commit" }
network_interface { "123_network_interface" }
fbos_dmesg_dump { "123_fbos_dmesg_dump" }
firmware_state { "123_firmware_state" }
ticket_identifier { rand(36**5).to_s(36) }
end
end