Popsuj plik, który już masz

Do testów na złych danych nie potrzebujesz przepisu. qadg corrupt bierze plik CSV, który już masz, psuje jego kopię i zapisuje obok niej manifest.

Uruchom

terminal
$ qadg corrupt --layers L2,L3,UNI,REV --seed readme customers.csv
customers: 1000 rows, 6 columns, nothing declared what any of them holds
       first_name taken for a column of string values, because no numbering scheme this build carries accepted 1000 values of this column, and its header is one this build reads as naming given names
       ...
       card taken for a column of card values, because every one of 1000 values of this column was accepted by the card validator, and by no other scheme carrying a check digit
...
customers.corrupted.csv and expectation-manifest.json written to .
46 defects ordered, 15 applied, manifest in expectation-manifest.json
...

Twój plik zostaje taki, jaki był. Popsuta kopia to customers.corrupted.csv, zapisana obok manifestu.

Co program ustala o twoich kolumnach

Nic w zwykłym pliku CSV nie mówi, co zawiera kolumna, więc qadg corrupt patrzy na wartości i na nagłówek. Kolumnę, której każda wartość przechodzi walidację numeru karty i nie przechodzi walidacji żadnego innego systemu z cyfrą kontrolną, uznaje za numery kart. Dla każdej kolumny program mówi, co ustalił i dlaczego, jak w liniach wyżej, i wypisuje to, czego nie umiał ustalić, zamiast zgadywać.

Uszkodzenie, które wymaga rodzaju kolumny, jakiego twój plik nie ma, trafia do manifestu jako niezastosowane, z powodem.

Wybierz, co popsuć

--layers jest wymagane, więc to zawsze ty wybierasz, co atakować. Co psuje wymienia każdą grupę i każdy rodzaj uszkodzenia w niej. --rows ustala udział wierszy do popsucia, domyślnie 5%.

--dry-run pokazuje, co program ustalił, ile wierszy by popsuł i jak, i niczego nie zapisuje. W małym pliku mały udział może nie wylosować żadnego wiersza i wtedy mówi o tym zarówno przebieg próbny, jak i prawdziwy.

Wszystkie flagi

FlagaCo robi
--layers <list>Which lines of defence to attack, such as L2,L3. Required, because there is no safe default.
--rows <share>The share of rows to damage, such as 5%. Defaults to 5%.
--out <dir>Write the damaged file and the manifest here. Defaults to the current directory.
--seed <text>Draw from this seed. The same seed and the same file give the same damage.
--delimiter <char>The character between fields, for reading and for writing back. Defaults to a comma.
--per-row <how>exactly_one or any, for how many defects one damaged row carries.
--exclude-fields <list>Columns to leave alone, whatever the layers say.
--locale <name>Which locale's damage is available. It does not decide what the columns hold, the values do. A locale this build has no data for is refused.
--manifest <form>Also write the manifest in this form beside the JSON one: gherkin, csv, markdown. Without it only the JSON is written.
--overwriteWrite over files that are already there. Without it an existing file stops the run.
--dry-runSay what was worked out and what would be damaged, and write nothing.

W oknie

Ekran Damage a file robi to samo: otwórz plik CSV, zobacz, co zawiera każda kolumna i dlaczego, zaznacz, co popsuć, zobacz, co by się stało, a potem uruchom. Pokazuje też polecenie, które robi to samo, gotowe do skopiowania.