Improve tests
This commit is contained in:
parent
c30c9b319d
commit
702f59a90e
|
@ -63,13 +63,19 @@ describe("getExternalSchema", () => {
|
||||||
it("can export a database with tables", async () => {
|
it("can export a database with tables", async () => {
|
||||||
const integration = new postgres.integration(config)
|
const integration = new postgres.integration(config)
|
||||||
|
|
||||||
integration.internalQuery({
|
await integration.internalQuery({
|
||||||
sql: `
|
sql: `
|
||||||
CREATE TABLE IF NOT EXISTS "users" (
|
CREATE TABLE "users" (
|
||||||
"id" SERIAL,
|
"id" SERIAL,
|
||||||
"name" VARCHAR(100) NOT NULL,
|
"name" VARCHAR(100) NOT NULL,
|
||||||
"role" VARCHAR(15) NOT NULL,
|
"role" VARCHAR(15) NOT NULL,
|
||||||
PRIMARY KEY ("id")
|
PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
CREATE TABLE "products" (
|
||||||
|
"id" SERIAL,
|
||||||
|
"name" VARCHAR(100) NOT NULL,
|
||||||
|
"price" DECIMAL NOT NULL,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
);`,
|
);`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -97,6 +103,41 @@ describe("getExternalSchema", () => {
|
||||||
|
|
||||||
SET default_table_access_method = heap;
|
SET default_table_access_method = heap;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products; Type: TABLE; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.products (
|
||||||
|
id integer NOT NULL,
|
||||||
|
name character varying(100) NOT NULL,
|
||||||
|
price numeric NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.products OWNER TO postgres;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.products_id_seq
|
||||||
|
AS integer
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.products_id_seq OWNER TO postgres;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.products_id_seq OWNED BY public.products.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
|
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
@ -132,6 +173,13 @@ describe("getExternalSchema", () => {
|
||||||
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.products ALTER COLUMN id SET DEFAULT nextval('public.products_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
|
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
@ -139,6 +187,14 @@ describe("getExternalSchema", () => {
|
||||||
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
|
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.products
|
||||||
|
ADD CONSTRAINT products_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
@ -158,8 +214,9 @@ describe("getExternalSchema", () => {
|
||||||
it("does not export a data", async () => {
|
it("does not export a data", async () => {
|
||||||
const integration = new postgres.integration(config)
|
const integration = new postgres.integration(config)
|
||||||
|
|
||||||
integration.internalQuery({
|
await integration.internalQuery({
|
||||||
sql: `INSERT INTO "users" ("name", "role") VALUES ('John Doe', 'Administrator');`,
|
sql: `INSERT INTO "users" ("name", "role") VALUES ('John Doe', 'Administrator');
|
||||||
|
INSERT INTO "products" ("name", "price") VALUES ('Book', 7.68);`,
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await integration.getExternalSchema()
|
const result = await integration.getExternalSchema()
|
||||||
|
@ -186,6 +243,41 @@ describe("getExternalSchema", () => {
|
||||||
|
|
||||||
SET default_table_access_method = heap;
|
SET default_table_access_method = heap;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products; Type: TABLE; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.products (
|
||||||
|
id integer NOT NULL,
|
||||||
|
name character varying(100) NOT NULL,
|
||||||
|
price numeric NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.products OWNER TO postgres;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.products_id_seq
|
||||||
|
AS integer
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE public.products_id_seq OWNER TO postgres;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.products_id_seq OWNED BY public.products.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
|
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
@ -221,6 +313,13 @@ describe("getExternalSchema", () => {
|
||||||
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.products ALTER COLUMN id SET DEFAULT nextval('public.products_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
|
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
@ -228,6 +327,14 @@ describe("getExternalSchema", () => {
|
||||||
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
|
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: products products_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.products
|
||||||
|
ADD CONSTRAINT products_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue